Patch "netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain()" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     netfilter-nf_tables-fix-nft_counters_enabled-underfl.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4bddeb6e5516bfbcef613ccbf494405ab1fdfa02
Author: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
Date:   Mon Sep 12 21:41:00 2022 +0900

    netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain()
    
    [ Upstream commit 921ebde3c0d22c8cba74ce8eb3cc4626abff1ccd ]
    
    syzbot is reporting underflow of nft_counters_enabled counter at
    nf_tables_addchain() [1], for commit 43eb8949cfdffa76 ("netfilter:
    nf_tables: do not leave chain stats enabled on error") missed that
    nf_tables_chain_destroy() after nft_basechain_init() in the error path of
    nf_tables_addchain() decrements the counter because nft_basechain_init()
    makes nft_is_base_chain() return true by setting NFT_CHAIN_BASE flag.
    
    Increment the counter immediately after returning from
    nft_basechain_init().
    
    Link:  https://syzkaller.appspot.com/bug?extid=b5d82a651b71cd8a75ab [1]
    Reported-by: syzbot <syzbot+b5d82a651b71cd8a75ab@xxxxxxxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
    Tested-by: syzbot <syzbot+b5d82a651b71cd8a75ab@xxxxxxxxxxxxxxxxxxxxxxxxx>
    Fixes: 43eb8949cfdffa76 ("netfilter: nf_tables: do not leave chain stats enabled on error")
    Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index b8e7e1c5c08a..d65c47bcbfc9 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2001,7 +2001,6 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
 			      u8 policy, u32 flags)
 {
 	const struct nlattr * const *nla = ctx->nla;
-	struct nft_stats __percpu *stats = NULL;
 	struct nft_table *table = ctx->table;
 	struct nft_base_chain *basechain;
 	struct net *net = ctx->net;
@@ -2015,6 +2014,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
 		return -EOVERFLOW;
 
 	if (nla[NFTA_CHAIN_HOOK]) {
+		struct nft_stats __percpu *stats = NULL;
 		struct nft_chain_hook hook;
 
 		if (flags & NFT_CHAIN_BINDING)
@@ -2047,6 +2047,8 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
 			kfree(basechain);
 			return err;
 		}
+		if (stats)
+			static_branch_inc(&nft_counters_enabled);
 	} else {
 		if (flags & NFT_CHAIN_BASE)
 			return -EINVAL;
@@ -2121,9 +2123,6 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
 		goto err_unregister_hook;
 	}
 
-	if (stats)
-		static_branch_inc(&nft_counters_enabled);
-
 	table->use++;
 
 	return 0;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux