Skip to contentSkip to conversation

WARNING in kfree

PATCH In review syzbot 2 participants 4 messages Aug 30, 2019 – Sep 6, 2019 VFS

lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following crash on:

HEAD commit:    ed2393ca Add linux-next specific files for 20190827
git tree:       linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=15ed648e600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=2ef5940a07ed45f4
dashboard link: https://syzkaller.appspot.com/bug?extid=5aca688dac0796c56129
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1595ee12600000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16df7fd2600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:

Reported-by [email protected]
------------[ cut here ]------------
virt_to_cache: Object is not a Slab page!
WARNING: CPU: 0 PID: 8815 at mm/slab.h:473 virt_to_cache mm/slab.h:473 [inline]
WARNING: CPU: 0 PID: 8815 at mm/slab.h:473 kfree+0x1d3/0x2c0 mm/slab.c:3748
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 8815 Comm: syz-executor970 Not tainted 5.3.0-rc6-next-20190827 #74
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
 panic+0x2dc/0x755 kernel/panic.c:220
 __warn.cold+0x2f/0x3c kernel/panic.c:581
 report_bug+0x289/0x300 lib/bug.c:195
 fixup_bug arch/x86/kernel/traps.c:179 [inline]
 fixup_bug arch/x86/kernel/traps.c:174 [inline]
 do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:272
 do_invalid_op+0x37/0x50 arch/x86/kernel/traps.c:291
 invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1028
RIP: 0010:virt_to_cache mm/slab.h:473 [inline]
RIP: 0010:kfree+0x1d3/0x2c0 mm/slab.c:3748
Code: 53 ff e9 67 fe ff ff 80 3d 5d e4 14 08 00 75 1c 48 c7 c6 a0 6c b5 87 48 c7 c7 d0 be a7 88 c6 05 46 e4 14 08 01 e8 d5 b8 96 ff <0f> 0b f6 c7 02 75 6d 48 83 3d 2e 23 46 07 00 0f 85 4b ff ff ff 0f
RSP: 0018:ffff888089e978e8 EFLAGS: 00010082
RAX: 0000000000000000 RBX: 0000000000000282 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff815bd606 RDI: ffffed10113d2f0f
RBP: ffff888089e97908 R08: ffff8880a03e0680 R09: ffffed1015d04109
R10: ffffed1015d04108 R11: ffff8880ae820847 R12: ffffffff81756100
R13: ffffffff829d0110 R14: ffff8880aa0bae80 R15: ffff88821b827170
 debugfs_release_dentry+0x60/0x80 fs/debugfs/inode.c:194
 __dentry_kill+0x3f7/0x600 fs/dcache.c:584
 shrink_dentry_list+0x152/0x4a0 fs/dcache.c:1120
 shrink_dcache_parent+0x23d/0x400 fs/dcache.c:1547
 do_one_tree+0x16/0x40 fs/dcache.c:1601
 shrink_dcache_for_umount+0x72/0x170 fs/dcache.c:1618
 generic_shutdown_super+0x6d/0x370 fs/super.c:445
 kill_anon_super+0x3e/0x60 fs/super.c:1104
 kill_litter_super+0x50/0x60 fs/super.c:1113
 deactivate_locked_super+0x95/0x100 fs/super.c:333
 deactivate_super fs/super.c:364 [inline]
 deactivate_super+0x1b2/0x1d0 fs/super.c:360
 put_fs_context+0xae/0x5b0 fs/fs_context.c:499
 fscontext_release+0x51/0x70 fs/fsopen.c:73
 __fput+0x2ff/0x890 fs/file_table.c:280
 ____fput+0x16/0x20 fs/file_table.c:313
 task_work_run+0x145/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x904/0x2e60 kernel/exit.c:879
 do_group_exit+0x135/0x360 kernel/exit.c:983
 __do_sys_exit_group kernel/exit.c:994 [inline]
 __se_sys_exit_group kernel/exit.c:992 [inline]
 __x64_sys_exit_group+0x44/0x50 kernel/exit.c:992
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x43fde8
Code: Bad RIP value.
RSP: 002b:00007ffd9fbe5158 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043fde8
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004bf670 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006d1180 R14: 0000000000000000 R15: 0000000000000000

Kernel Offset: disabled
Rebooting in 86400 seconds..

---
This bug 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 [email protected].

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

#1 lore raw

PATCH 1/1 vfs: fix vfs_get_single_reconf_super error handling

From: Eric Biggers <[email protected]>

syzbot reported an invalid free in debugfs_release_dentry(). The reproducer tries to mount debugfs with the 'dirsync' option, which is not allowed. The bug is that if reconfigure_super() fails in vfs_get_super(), deactivate_locked_super() is called, but also fs_context::root is left non-NULL which causes deactivate_super() to be called again later.

Fix it by releasing fs_context::root in the error path.

Reported-by [email protected]
Fixes e478b48498a7 ("vfs: Add a single-or-reconfig keying to vfs_get_super()")
Cc David Howells <[email protected]>
---
 fs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/super.c +4 -1
index 0f913376fc4c..99195e15be05 100644
@@ -1194,8 +1194,11 @@ int vfs_get_super(struct fs_context *fc,
 		fc->root = dget(sb->s_root);
 		if (keying == vfs_get_single_reconf_super) {
 			err = reconfigure_super(fc);
-			if (err < 0)
+			if (err < 0) {
+				dput(fc->root);
+				fc->root = NULL;
 				goto error;
+			}
 		}
 	}
 
Signature · 1 line
2.23.0
#2 lore raw

Re: [PATCH vfs/for-next] vfs: fix vfs_get_single_reconf_super error handling

Quoted 26 lines · Eric Biggers

From: Eric Biggers <[email protected]>

syzbot reported an invalid free in debugfs_release_dentry(). The reproducer tries to mount debugfs with the 'dirsync' option, which is not allowed. The bug is that if reconfigure_super() fails in vfs_get_super(), deactivate_locked_super() is called, but also fs_context::root is left non-NULL which causes deactivate_super() to be called again later.

Fix it by releasing fs_context::root in the error path.

Reported-by [email protected]
Fixes e478b48498a7 ("vfs: Add a single-or-reconfig keying to vfs_get_super()")
Cc David Howells <[email protected]>
---
 fs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/super.c +0 -0
index 0f913376fc4c..99195e15be05 100644
@@ -1194,8 +1194,11 @@ int vfs_get_super(struct fs_context *fc,
 		fc->root = dget(sb->s_root);
 		if (keying == vfs_get_single_reconf_super) {

fs/super.c int vfs_get_super(struct fs_context *fc, · line 1204

Quoted 10 lines
fs/super.c +4 -1
 			err = reconfigure_super(fc);
-			if (err < 0)
+			if (err < 0) {
+				dput(fc->root);
+				fc->root = NULL;
 				goto error;
+			}
 		}
 	}
 

Ping. This is still broken in linux-next.

- Eric

author syzbot
#3 lore raw
In reply to syzbot
syzbot has bisected this bug to:

syzbot has bisected this bug to:

commit 3deadeebafcec6a0a7c9397bd32ea5ac6d5191c1

Author: David Howells <[email protected]>
Date:   Mon Jan 21 14:04:22 2019 +0000

vfs: Convert debugfs to use the new mount API

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=115d9e56600000
start commit:   ed2393ca Add linux-next specific files for 20190827
git tree:       linux-next
final crash:    https://syzkaller.appspot.com/x/report.txt?x=135d9e56600000
console output: https://syzkaller.appspot.com/x/log.txt?x=155d9e56600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=2ef5940a07ed45f4
dashboard link: https://syzkaller.appspot.com/bug?extid=5aca688dac0796c56129
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1595ee12600000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16df7fd2600000
Reported-by [email protected]
Fixes 3deadeebafce ("vfs: Convert debugfs to use the new mount API")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection