[syzbot] WARNING in static_key_slow_try_dec (3)

11 views
Skip to first unread message

syzbot

unread,
Sep 6, 2022, 6:48:28 AM9/6/22
to ar...@kernel.org, jba...@akamai.com, jpoi...@kernel.org, linux-...@vger.kernel.org, pet...@infradead.org, ros...@goodmis.org, syzkall...@googlegroups.com
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+b5d82a...@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 syzk...@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

syzbot

unread,
Sep 12, 2022, 7:57:12 AM9/12/22
to penguin...@i-love.sakura.ne.jp, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+b5d82a...@syzkaller.appspotmail.com

Tested on:

commit: 80e78fcc Linux 6.0-rc5
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15002577080000
kernel config: https://syzkaller.appspot.com/x/.config?x=21f69a9380d79ca9
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
patch: https://syzkaller.appspot.com/x/patch.diff?x=11cc3e10880000

Note: testing is done by a robot and is best-effort only.

Tetsuo Handa

unread,
Sep 12, 2022, 8:41:27 AM9/12/22
to Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal, syzbot, syzkall...@googlegroups.com, netfilt...@vger.kernel.org, core...@netfilter.org, 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+b5d82a...@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin...@I-love.SAKURA.ne.jp>
Tested-by: syzbot <syzbot+b5d82a...@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

Pablo Neira Ayuso

unread,
Sep 12, 2022, 8:45:03 AM9/12/22
to Tetsuo Handa, Jozsef Kadlecsik, Florian Westphal, syzbot, syzkall...@googlegroups.com, netfilt...@vger.kernel.org, core...@netfilter.org, 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

Florian Westphal

unread,
Sep 15, 2022, 4:19:53 PM9/15/22
to Tetsuo Handa, Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal, syzbot, syzkall...@googlegroups.com, netfilt...@vger.kernel.org, core...@netfilter.org, Network Development
Tetsuo Handa <penguin...@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.
Reply all
Reply to author
Forward
0 new messages