* [syzbot] WARNING in static_key_slow_try_dec (3) @ 2022-09-06 10:48 syzbot 2022-09-12 12:41 ` [PATCH] netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain() Tetsuo Handa 0 siblings, 1 reply; 4+ messages in thread From: syzbot @ 2022-09-06 10:48 UTC (permalink / raw) To: ardb, jbaron, jpoimboe, linux-kernel, peterz, rostedt, syzkaller-bugs Hello, syzbot found the following issue on: HEAD commit: 42cf58c272ee Merge tag 'tty-6.0-rc4' of git://git.kernel.o.. git tree: upstream console+strace: https://syzkaller.appspot.com/x/log.txt?x=10239be7080000 kernel config: https://syzkaller.appspot.com/x/.config?x=892a57667b7af6cf dashboard link: https://syzkaller.appspot.com/bug?extid=b5d82a651b71cd8a75ab compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15065393080000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11b22817080000 Downloadable assets: disk image: https://storage.googleapis.com/syzbot-assets/0cddb4889822/disk-42cf58c2.raw.xz vmlinux: https://storage.googleapis.com/syzbot-assets/86b24f0bd2f9/vmlinux-42cf58c2.xz IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+b5d82a651b71cd8a75ab@syzkaller.appspotmail.com ------------[ cut here ]------------ jump label: negative count! WARNING: CPU: 1 PID: 3629 at kernel/jump_label.c:235 static_key_slow_try_dec+0xca/0xe0 kernel/jump_label.c:235 Modules linked in: CPU: 1 PID: 3629 Comm: syz-executor307 Not tainted 6.0.0-rc3-syzkaller-00328-g42cf58c272ee #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022 RIP: 0010:static_key_slow_try_dec+0xca/0xe0 kernel/jump_label.c:235 Code: 5d c3 e8 79 16 d9 ff 45 31 ed 5b 44 89 e8 5d 41 5c 41 5d c3 44 89 e5 eb 8e e8 62 16 d9 ff 48 c7 c7 60 b8 f6 89 e8 c3 68 97 07 <0f> 0b eb c5 48 89 df e8 1a 76 25 00 e9 6a ff ff ff 0f 1f 44 00 00 RSP: 0018:ffffc900038af078 EFLAGS: 00010282 RAX: 0000000000000000 RBX: ffffffff915443a0 RCX: 0000000000000000 RDX: ffff88801dee5880 RSI: ffffffff8161f408 RDI: fffff52000715e01 RBP: 00000000ffffffff R08: 0000000000000005 R09: 0000000000000000 R10: 0000000080000000 R11: 0000000000000000 R12: 00000000ffffffff R13: ffff888012709601 R14: 0000000000000001 R15: ffff888012709628 FS: 0000555555620300(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffe1aacdaf8 CR3: 000000001ce9e000 CR4: 0000000000350ef0 Call Trace: <TASK> __static_key_slow_dec_cpuslocked kernel/jump_label.c:243 [inline] __static_key_slow_dec kernel/jump_label.c:255 [inline] static_key_slow_dec+0x5c/0xc0 kernel/jump_label.c:270 nf_tables_chain_destroy+0x250/0x640 net/netfilter/nf_tables_api.c:1880 nf_tables_addchain.constprop.0+0xc56/0x16e0 net/netfilter/nf_tables_api.c:2329 nf_tables_newchain+0x16d1/0x1ef0 net/netfilter/nf_tables_api.c:2593 nfnetlink_rcv_batch+0x1721/0x2600 net/netfilter/nfnetlink.c:517 nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:638 [inline] nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:656 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline] netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345 netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921 sock_sendmsg_nosec net/socket.c:714 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:734 ____sys_sendmsg+0x6eb/0x810 net/socket.c:2482 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2536 __sys_sendmsg+0xf3/0x1c0 net/socket.c:2565 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f136a7cf0c9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 41 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffe1aacdb18 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f136a7cf0c9 RDX: 0000000000000000 RSI: 000000002000c2c0 RDI: 0000000000000004 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffe1aacdb30 R13: 00000000000f4240 R14: 000000000000b1ac R15: 00007ffe1aacdb24 </TASK> --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this issue, for details see: https://goo.gl/tpsmEJ#testing-patches ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain() 2022-09-06 10:48 [syzbot] WARNING in static_key_slow_try_dec (3) syzbot @ 2022-09-12 12:41 ` Tetsuo Handa 2022-09-12 12:44 ` Pablo Neira Ayuso 2022-09-15 20:19 ` Florian Westphal 0 siblings, 2 replies; 4+ messages in thread From: Tetsuo Handa @ 2022-09-12 12:41 UTC (permalink / raw) To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal Cc: syzbot, syzkaller-bugs, netfilter-devel, coreteam, Network Development 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@syzkaller.appspotmail.com> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Tested-by: syzbot <syzbot+b5d82a651b71cd8a75ab@syzkaller.appspotmail.com> Fixes: 43eb8949cfdffa76 ("netfilter: nf_tables: do not leave chain stats enabled on error") --- net/netfilter/nf_tables_api.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 816052089b33..e062754dc6cc 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -2197,7 +2197,6 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, struct netlink_ext_ack *extack) { 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; @@ -2212,6 +2211,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) @@ -2245,6 +2245,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; @@ -2319,9 +2321,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; -- 2.18.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain() 2022-09-12 12:41 ` [PATCH] netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain() Tetsuo Handa @ 2022-09-12 12:44 ` Pablo Neira Ayuso 2022-09-15 20:19 ` Florian Westphal 1 sibling, 0 replies; 4+ messages in thread From: Pablo Neira Ayuso @ 2022-09-12 12:44 UTC (permalink / raw) To: Tetsuo Handa Cc: Jozsef Kadlecsik, Florian Westphal, syzbot, syzkaller-bugs, netfilter-devel, coreteam, Network Development On Mon, Sep 12, 2022 at 09:41:00PM +0900, Tetsuo Handa wrote: > 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(). Patch LGTM, thanks > Link: https://syzkaller.appspot.com/bug?extid=b5d82a651b71cd8a75ab [1] > Reported-by: syzbot <syzbot+b5d82a651b71cd8a75ab@syzkaller.appspotmail.com> > Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > Tested-by: syzbot <syzbot+b5d82a651b71cd8a75ab@syzkaller.appspotmail.com> > Fixes: 43eb8949cfdffa76 ("netfilter: nf_tables: do not leave chain stats enabled on error") > --- > net/netfilter/nf_tables_api.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c > index 816052089b33..e062754dc6cc 100644 > --- a/net/netfilter/nf_tables_api.c > +++ b/net/netfilter/nf_tables_api.c > @@ -2197,7 +2197,6 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, > struct netlink_ext_ack *extack) > { > 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; > @@ -2212,6 +2211,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) > @@ -2245,6 +2245,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; > @@ -2319,9 +2321,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; > -- > 2.18.4 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain() 2022-09-12 12:41 ` [PATCH] netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain() Tetsuo Handa 2022-09-12 12:44 ` Pablo Neira Ayuso @ 2022-09-15 20:19 ` Florian Westphal 1 sibling, 0 replies; 4+ messages in thread From: Florian Westphal @ 2022-09-15 20:19 UTC (permalink / raw) To: Tetsuo Handa Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal, syzbot, syzkaller-bugs, netfilter-devel, coreteam, Network Development Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote: > 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(). Applied, thanks. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-15 20:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-09-06 10:48 [syzbot] WARNING in static_key_slow_try_dec (3) syzbot 2022-09-12 12:41 ` [PATCH] netfilter: nf_tables: fix nft_counters_enabled underflow at nf_tables_addchain() Tetsuo Handa 2022-09-12 12:44 ` Pablo Neira Ayuso 2022-09-15 20:19 ` Florian Westphal
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.