[syzbot] WARNING in kernfs_active

13 views
Skip to first unread message

syzbot

unread,
Oct 10, 2022, 3:16:44 AM10/10/22
to gre...@linuxfoundation.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com, t...@kernel.org
Hello,

syzbot found the following issue on:

HEAD commit: 4899a36f91a9 Merge tag 'powerpc-6.1-1' of git://git.kernel..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15428b1c880000
kernel config: https://syzkaller.appspot.com/x/.config?x=82d4dadec8e02fa1
dashboard link: https://syzkaller.appspot.com/bug?extid=590ce62b128e79cf0a35
compiler: aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+590ce6...@syzkaller.appspotmail.com

------------[ cut here ]------------
WARNING: CPU: 1 PID: 6191 at fs/kernfs/dir.c:36 kernfs_active+0xe8/0x120 fs/kernfs/dir.c:38
Modules linked in:
CPU: 1 PID: 6191 Comm: syz-executor.1 Not tainted 6.0.0-syzkaller-09413-g4899a36f91a9 #0
Hardware name: linux,dummy-virt (DT)
pstate: 10000005 (nzcV daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : kernfs_active+0xe8/0x120 fs/kernfs/dir.c:36
lr : lock_is_held include/linux/lockdep.h:283 [inline]
lr : kernfs_active+0x94/0x120 fs/kernfs/dir.c:36
sp : ffff8000182c7a00
x29: ffff8000182c7a00 x28: 0000000000000002 x27: 0000000000000001
x26: ffff00000ee1f6a8 x25: 1fffe00001dc3ed5 x24: 0000000000000000
x23: ffff80000ca1fba0 x22: ffff8000089efcb0 x21: 0000000000000001
x20: ffff0000091181d0 x19: ffff0000091181d0 x18: ffff00006a9e6b88
x17: 0000000000000000 x16: 0000000000000000 x15: ffff00006a9e6bc4
x14: 1ffff00003058f0e x13: 1fffe0000258c816 x12: ffff700003058f39
x11: 1ffff00003058f38 x10: ffff700003058f38 x9 : dfff800000000000
x8 : ffff80000e482f20 x7 : ffff0000091d8058 x6 : ffff80000e482c60
x5 : ffff000009402ee8 x4 : 1ffff00001bd1f46 x3 : 1fffe0000258c6d1
x2 : 0000000000000003 x1 : 00000000000000c0 x0 : 0000000000000000
Call trace:
kernfs_active+0xe8/0x120 fs/kernfs/dir.c:38
kernfs_find_and_get_node_by_id+0x6c/0x140 fs/kernfs/dir.c:708
__kernfs_fh_to_dentry fs/kernfs/mount.c:102 [inline]
kernfs_fh_to_dentry+0x88/0x1fc fs/kernfs/mount.c:128
exportfs_decode_fh_raw+0x104/0x560 fs/exportfs/expfs.c:435
exportfs_decode_fh+0x10/0x5c fs/exportfs/expfs.c:575
do_handle_to_path fs/fhandle.c:152 [inline]
handle_to_path fs/fhandle.c:207 [inline]
do_handle_open+0x2a4/0x7b0 fs/fhandle.c:223
__do_compat_sys_open_by_handle_at fs/fhandle.c:277 [inline]
__se_compat_sys_open_by_handle_at fs/fhandle.c:274 [inline]
__arm64_compat_sys_open_by_handle_at+0x6c/0x9c fs/fhandle.c:274
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x6c/0x260 arch/arm64/kernel/syscall.c:52
el0_svc_common.constprop.0+0xc4/0x254 arch/arm64/kernel/syscall.c:142
do_el0_svc_compat+0x40/0x70 arch/arm64/kernel/syscall.c:212
el0_svc_compat+0x54/0x140 arch/arm64/kernel/entry-common.c:772
el0t_32_sync_handler+0x90/0x140 arch/arm64/kernel/entry-common.c:782
el0t_32_sync+0x190/0x194 arch/arm64/kernel/entry.S:586
irq event stamp: 232
hardirqs last enabled at (231): [<ffff8000081edf70>] raw_spin_rq_unlock_irq kernel/sched/sched.h:1367 [inline]
hardirqs last enabled at (231): [<ffff8000081edf70>] finish_lock_switch kernel/sched/core.c:4943 [inline]
hardirqs last enabled at (231): [<ffff8000081edf70>] finish_task_switch.isra.0+0x200/0x880 kernel/sched/core.c:5061
hardirqs last disabled at (232): [<ffff80000c888bb4>] el1_dbg+0x24/0x80 arch/arm64/kernel/entry-common.c:404
softirqs last enabled at (228): [<ffff800008010938>] _stext+0x938/0xf58
softirqs last disabled at (207): [<ffff800008019380>] ____do_softirq+0x10/0x20 arch/arm64/kernel/irq.c:79
---[ end trace 0000000000000000 ]---


---
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.

Dmitry Vyukov

unread,
Oct 10, 2022, 3:34:22 AM10/10/22
to syzbot, bra...@kernel.org, Amir Goldstein, Miklos Szeredi, gre...@linuxfoundation.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com, t...@kernel.org
On Mon, 10 Oct 2022 at 09:16, syzbot
<syzbot+590ce6...@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 4899a36f91a9 Merge tag 'powerpc-6.1-1' of git://git.kernel..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=15428b1c880000
> kernel config: https://syzkaller.appspot.com/x/.config?x=82d4dadec8e02fa1
> dashboard link: https://syzkaller.appspot.com/bug?extid=590ce62b128e79cf0a35
> compiler: aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> userspace arch: arm
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+590ce6...@syzkaller.appspotmail.com

+exportfs maintainers (it looks like exportfs is the root cause)
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bug...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/00000000000013300305eaa8f1bf%40google.com.

Amir Goldstein

unread,
Oct 10, 2022, 1:42:56 PM10/10/22
to Dmitry Vyukov, t...@kernel.org, syzbot, bra...@kernel.org, Miklos Szeredi, gre...@linuxfoundation.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Mon, Oct 10, 2022 at 10:34 AM Dmitry Vyukov <dvy...@google.com> wrote:
>
> On Mon, 10 Oct 2022 at 09:16, syzbot
> <syzbot+590ce6...@syzkaller.appspotmail.com> wrote:
> >
> > Hello,
> >
> > syzbot found the following issue on:
> >
> > HEAD commit: 4899a36f91a9 Merge tag 'powerpc-6.1-1' of git://git.kernel..
> > git tree: upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=15428b1c880000
> > kernel config: https://syzkaller.appspot.com/x/.config?x=82d4dadec8e02fa1
> > dashboard link: https://syzkaller.appspot.com/bug?extid=590ce62b128e79cf0a35
> > compiler: aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> > userspace arch: arm
> >
> > Unfortunately, I don't have any reproducer for this issue yet.
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+590ce6...@syzkaller.appspotmail.com
>
> +exportfs maintainers (it looks like exportfs is the root cause)

What makes you say that?
And who are the "exportfs maintainers"?
As far as I can see the only MAINTAINERS filter to match exportfs is
fs/* (i.e. vfs)

The regressing commit is most likely:

c25491747b21 kernfs: Add KERNFS_REMOVING flags

Because before it, this specific stack trace was not possible.
kernfs_active() was not called from kernfs_find_and_get_node_by_id().

Thanks,
Amir.

Tejun Heo

unread,
Oct 10, 2022, 7:54:19 PM10/10/22
to gre...@linuxfoundation.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com, syzbot, Amir Goldstein, Dmitry Vyukov
c25491747b21 ("kernfs: Add KERNFS_REMOVING flags") made
kernfs_find_and_get_node_by_id() test kernfs_active() instead of
KERNFS_ACTIVATED. kernfs_find_and_get_by_id() is called without holding the
kernfs_rwsem triggering the following lockdep warning.
The lockdep warning in kernfs_active() is there to ensure that the activated
state stays stable for the caller. For kernfs_find_and_get_node_by_id(), all
that's needed is ensuring that a node which has never been activated can't
be looked up and guaranteeing lookup success when the caller knows the node
to be active, both of which can be achieved by testing the active count
without holding the kernfs_rwsem.

Fix the spurious warning by introducing __kernfs_active() which doesn't have
the lockdep annotation.

Signed-off-by: Tejun Heo <t...@kernel.org>
Reported-by: syzbot+590ce6...@syzkaller.appspotmail.com
Fixes: c25491747b21 ("kernfs: Add KERNFS_REMOVING flags")
Cc: Amir Goldstein <amir...@gmail.com>
Cc: Dmitry Vyukov <dvy...@google.com>
---
fs/kernfs/dir.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 3990f3e270cb6..f33b3baad07cb 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -31,10 +31,15 @@ static DEFINE_SPINLOCK(kernfs_idr_lock); /* root->ino_idr */

#define rb_to_kn(X) rb_entry((X), struct kernfs_node, rb)

+static bool __kernfs_active(struct kernfs_node *kn)
+{
+ return atomic_read(&kn->active) >= 0;
+}
+
static bool kernfs_active(struct kernfs_node *kn)
{
lockdep_assert_held(&kernfs_root(kn)->kernfs_rwsem);
- return atomic_read(&kn->active) >= 0;
+ return __kernfs_active(kn);
}

static bool kernfs_lockdep(struct kernfs_node *kn)
@@ -705,7 +710,12 @@ struct kernfs_node *kernfs_find_and_get_node_by_id(struct kernfs_root *root,
goto err_unlock;
}

- if (unlikely(!kernfs_active(kn) || !atomic_inc_not_zero(&kn->count)))
+ /*
+ * We should fail if @kn has never been activated and guarantee success
+ * if the caller knows that @kn is active. Both can be achieved by
+ * __kernfs_active() which tests @kn->active without kernfs_rwsem.
+ */
+ if (unlikely(!__kernfs_active(kn) || !atomic_inc_not_zero(&kn->count)))
goto err_unlock;

spin_unlock(&kernfs_idr_lock);

Dmitry Vyukov

unread,
Oct 12, 2022, 3:58:44 AM10/12/22
to Amir Goldstein, t...@kernel.org, syzbot, bra...@kernel.org, Miklos Szeredi, gre...@linuxfoundation.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Mon, 10 Oct 2022 at 19:42, Amir Goldstein <amir...@gmail.com> wrote:
> > On Mon, 10 Oct 2022 at 09:16, syzbot
> > <syzbot+590ce6...@syzkaller.appspotmail.com> wrote:
> > >
> > > Hello,
> > >
> > > syzbot found the following issue on:
> > >
> > > HEAD commit: 4899a36f91a9 Merge tag 'powerpc-6.1-1' of git://git.kernel..
> > > git tree: upstream
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=15428b1c880000
> > > kernel config: https://syzkaller.appspot.com/x/.config?x=82d4dadec8e02fa1
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=590ce62b128e79cf0a35
> > > compiler: aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> > > userspace arch: arm
> > >
> > > Unfortunately, I don't have any reproducer for this issue yet.
> > >
> > > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > > Reported-by: syzbot+590ce6...@syzkaller.appspotmail.com
> >
> > +exportfs maintainers (it looks like exportfs is the root cause)
>
> What makes you say that?

Hi Amir,

The intuition after looking at several thousands of kernel oopses
suggests that here:

kernfs_fh_to_dentry+0x88/0x1fc fs/kernfs/mount.c:128
exportfs_decode_fh_raw+0x104/0x560 fs/exportfs/expfs.c:435

the more specific fs/exportfs/expfs.c is more likely to be the root
cause than the more widely used fs/kernfs/mount.c.


> And who are the "exportfs maintainers"?

I use the output of "scripts/get_maintainer.pl -f fs/exportfs/expfs.c".
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/CAOQ4uxg%2BtM%2BheZ8f739SmMz-fBDDgc68hER%2B-iyBU%2B2q73VZWQ%40mail.gmail.com.

syzbot

unread,
Nov 2, 2022, 10:48:46 PM11/2/22
to amir...@gmail.com, bra...@kernel.org, dvy...@google.com, gre...@linuxfoundation.org, linux-...@vger.kernel.org, msze...@redhat.com, syzkall...@googlegroups.com, t...@kernel.org
syzbot has found a reproducer for the following issue on:

HEAD commit: 61c3426aca2c Add linux-next specific files for 20221102
git tree: linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=12c40689880000
kernel config: https://syzkaller.appspot.com/x/.config?x=acb529cc910d907c
dashboard link: https://syzkaller.appspot.com/bug?extid=590ce62b128e79cf0a35
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=1457cdda880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=179969da880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/cc56d88dd6a3/disk-61c3426a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5921b65b080f/vmlinux-61c3426a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/39cbd355fedd/bzImage-61c3426a.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+590ce6...@syzkaller.appspotmail.com

------------[ cut here ]------------
WARNING: CPU: 1 PID: 5234 at fs/kernfs/dir.c:36 kernfs_active+0x119/0x150 fs/kernfs/dir.c:36
Modules linked in:
CPU: 1 PID: 5234 Comm: syz-executor157 Not tainted 6.1.0-rc3-next-20221102-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022
RIP: 0010:kernfs_active+0x119/0x150 fs/kernfs/dir.c:36
Code: e8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 1f 8b 5b 04 31 ff 89 de e8 06 9a 7e ff 89 d8 5b f7 d0 5d c1 e8 1f c3 e8 27 9d 7e ff <0f> 0b eb a5 48 89 ef e8 eb 2a cb ff eb d7 48 c7 c7 2c 1a e3 8d e8
RSP: 0018:ffffc90003cdfbc0 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff8881400f31d0 RCX: 0000000000000000
RDX: ffff88802707d7c0 RSI: ffffffff81fe4429 RDI: 0000000000000005
RBP: 0000000000000000 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff8881400f31d0
R13: ffff88802a48e000 R14: 0000000000000000 R15: 0000000000000001
FS: 0000555555ffe300(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000005f6b40 CR3: 000000007edff000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
kernfs_find_and_get_node_by_id+0x84/0x170 fs/kernfs/dir.c:708
__kernfs_fh_to_dentry+0xdb/0x270 fs/kernfs/mount.c:102
exportfs_decode_fh_raw+0x127/0x7b0 fs/exportfs/expfs.c:435
exportfs_decode_fh+0x38/0x90 fs/exportfs/expfs.c:575
do_handle_to_path fs/fhandle.c:152 [inline]
handle_to_path fs/fhandle.c:207 [inline]
do_handle_open+0x2b6/0x8b0 fs/fhandle.c:223
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:0x7f51080a6ba9
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 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:00007ffcd1c41c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000130
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f51080a6ba9
RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000000005
RBP: 00007f510806ad50 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f510806ade0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>

Reply all
Reply to author
Forward
0 new messages