* KMSAN: uninit-value in f2fs_lookup @ 2020-09-25 5:18 syzbot 2020-09-25 9:06 ` [f2fs-dev] " Chao Yu 0 siblings, 1 reply; 7+ messages in thread From: syzbot @ 2020-09-25 5:18 UTC (permalink / raw) To: chao, glider, jaegeuk, linux-f2fs-devel, linux-kernel, syzkaller-bugs Hello, syzbot found the following issue on: HEAD commit: c5a13b33 kmsan: clang-format core git tree: https://github.com/google/kmsan.git master console output: https://syzkaller.appspot.com/x/log.txt?x=14f5b19b900000 kernel config: https://syzkaller.appspot.com/x/.config?x=20f149ad694ba4be dashboard link: https://syzkaller.appspot.com/bug?extid=0eac6f0bbd558fd866d7 compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) userspace arch: i386 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+0eac6f0bbd558fd866d7@syzkaller.appspotmail.com ===================================================== BUG: KMSAN: uninit-value in f2fs_lookup+0xe05/0x1a80 fs/f2fs/namei.c:503 CPU: 0 PID: 20216 Comm: syz-executor.5 Not tainted 5.9.0-rc4-syzkaller #0 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+0x21c/0x280 lib/dump_stack.c:118 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:122 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:219 f2fs_lookup+0xe05/0x1a80 fs/f2fs/namei.c:503 lookup_open fs/namei.c:3082 [inline] open_last_lookups fs/namei.c:3177 [inline] path_openat+0x2729/0x6a90 fs/namei.c:3365 do_filp_open+0x2b8/0x710 fs/namei.c:3395 do_sys_openat2+0xa88/0x1140 fs/open.c:1168 do_sys_open fs/open.c:1184 [inline] __do_compat_sys_openat fs/open.c:1242 [inline] __se_compat_sys_openat+0x2a4/0x310 fs/open.c:1240 __ia32_compat_sys_openat+0x56/0x70 fs/open.c:1240 do_syscall_32_irqs_on arch/x86/entry/common.c:80 [inline] __do_fast_syscall_32+0x129/0x180 arch/x86/entry/common.c:139 do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:162 do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:205 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c RIP: 0023:0xf7f73549 Code: b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 00 00 00 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 eb 0d 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 002b:00000000f554c0cc EFLAGS: 00000296 ORIG_RAX: 0000000000000127 RAX: ffffffffffffffda RBX: 00000000ffffff9c RCX: 0000000020000980 RDX: 000000000002f042 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Local variable ----page@f2fs_lookup created at: f2fs_lookup+0x8f/0x1a80 fs/f2fs/namei.c:477 f2fs_lookup+0x8f/0x1a80 fs/f2fs/namei.c:477 ===================================================== --- 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. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [f2fs-dev] KMSAN: uninit-value in f2fs_lookup 2020-09-25 5:18 KMSAN: uninit-value in f2fs_lookup syzbot @ 2020-09-25 9:06 ` Chao Yu 2020-09-25 10:57 ` Dan Carpenter 2020-09-25 16:38 ` Eric Biggers 0 siblings, 2 replies; 7+ messages in thread From: Chao Yu @ 2020-09-25 9:06 UTC (permalink / raw) To: syzbot, chao, glider, jaegeuk, linux-f2fs-devel, linux-kernel, syzkaller-bugs Hi, I don't see any problem here, thanks for your report. :) Thanks, On 2020/9/25 13:18, syzbot wrote: > Hello, > > syzbot found the following issue on: > > HEAD commit: c5a13b33 kmsan: clang-format core > git tree: https://github.com/google/kmsan.git master > console output: https://syzkaller.appspot.com/x/log.txt?x=14f5b19b900000 > kernel config: https://syzkaller.appspot.com/x/.config?x=20f149ad694ba4be > dashboard link: https://syzkaller.appspot.com/bug?extid=0eac6f0bbd558fd866d7 > compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) > userspace arch: i386 > > 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+0eac6f0bbd558fd866d7@syzkaller.appspotmail.com > > ===================================================== > BUG: KMSAN: uninit-value in f2fs_lookup+0xe05/0x1a80 fs/f2fs/namei.c:503 > CPU: 0 PID: 20216 Comm: syz-executor.5 Not tainted 5.9.0-rc4-syzkaller #0 > 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+0x21c/0x280 lib/dump_stack.c:118 > kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:122 > __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:219 > f2fs_lookup+0xe05/0x1a80 fs/f2fs/namei.c:503 > lookup_open fs/namei.c:3082 [inline] > open_last_lookups fs/namei.c:3177 [inline] > path_openat+0x2729/0x6a90 fs/namei.c:3365 > do_filp_open+0x2b8/0x710 fs/namei.c:3395 > do_sys_openat2+0xa88/0x1140 fs/open.c:1168 > do_sys_open fs/open.c:1184 [inline] > __do_compat_sys_openat fs/open.c:1242 [inline] > __se_compat_sys_openat+0x2a4/0x310 fs/open.c:1240 > __ia32_compat_sys_openat+0x56/0x70 fs/open.c:1240 > do_syscall_32_irqs_on arch/x86/entry/common.c:80 [inline] > __do_fast_syscall_32+0x129/0x180 arch/x86/entry/common.c:139 > do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:162 > do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:205 > entry_SYSENTER_compat_after_hwframe+0x4d/0x5c > RIP: 0023:0xf7f73549 > Code: b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 00 00 00 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 eb 0d 90 90 90 90 90 90 90 90 90 90 90 90 > RSP: 002b:00000000f554c0cc EFLAGS: 00000296 ORIG_RAX: 0000000000000127 > RAX: ffffffffffffffda RBX: 00000000ffffff9c RCX: 0000000020000980 > RDX: 000000000002f042 RSI: 0000000000000000 RDI: 0000000000000000 > RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 > R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 > R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 > > Local variable ----page@f2fs_lookup created at: > f2fs_lookup+0x8f/0x1a80 fs/f2fs/namei.c:477 > f2fs_lookup+0x8f/0x1a80 fs/f2fs/namei.c:477 > ===================================================== > > > --- > 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. > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > . > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [f2fs-dev] KMSAN: uninit-value in f2fs_lookup 2020-09-25 9:06 ` [f2fs-dev] " Chao Yu @ 2020-09-25 10:57 ` Dan Carpenter 2020-09-25 15:01 ` Chao Yu 2020-09-25 16:38 ` Eric Biggers 1 sibling, 1 reply; 7+ messages in thread From: Dan Carpenter @ 2020-09-25 10:57 UTC (permalink / raw) To: Chao Yu Cc: syzbot, chao, glider, jaegeuk, linux-f2fs-devel, linux-kernel, syzkaller-bugs On Fri, Sep 25, 2020 at 05:06:33PM +0800, Chao Yu wrote: > Hi, > > I don't see any problem here, thanks for your report. :) > I bet the uninitialize value is because "max_depth" is zero. 352 struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, 353 const struct f2fs_filename *fname, 354 struct page **res_page) ^^^^^^^^ The stack trace says this isn't initialized. 355 { 356 unsigned long npages = dir_blocks(dir); 357 struct f2fs_dir_entry *de = NULL; 358 unsigned int max_depth; 359 unsigned int level; 360 361 if (f2fs_has_inline_dentry(dir)) { 362 *res_page = NULL; 363 de = f2fs_find_in_inline_dir(dir, fname, res_page); 364 goto out; 365 } 366 367 if (npages == 0) { 368 *res_page = NULL; 369 goto out; 370 } 371 372 max_depth = F2FS_I(dir)->i_current_depth; 373 if (unlikely(max_depth > MAX_DIR_HASH_DEPTH)) { 374 f2fs_warn(F2FS_I_SB(dir), "Corrupted max_depth of %lu: %u", 375 dir->i_ino, max_depth); 376 max_depth = MAX_DIR_HASH_DEPTH; 377 f2fs_i_depth_write(dir, max_depth); 378 } 379 380 for (level = 0; level < max_depth; level++) { ^^^^^^^^^^^^^^^^^ If "max_depth" is zero, then we never enter this loop. 381 *res_page = NULL; 382 de = find_in_level(dir, level, fname, res_page); 383 if (de || IS_ERR(*res_page)) 384 break; 385 } 386 out: 387 /* This is to increase the speed of f2fs_create */ 388 if (!de) 389 F2FS_I(dir)->task = current; 390 return de; Which means that we return a NULL "de" and "*res_page" is uninitialized and that matches what syzbot found throug runtime testing. 391 } regards, dan carpenter ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [f2fs-dev] KMSAN: uninit-value in f2fs_lookup 2020-09-25 10:57 ` Dan Carpenter @ 2020-09-25 15:01 ` Chao Yu 0 siblings, 0 replies; 7+ messages in thread From: Chao Yu @ 2020-09-25 15:01 UTC (permalink / raw) To: Dan Carpenter, Chao Yu Cc: syzbot, glider, jaegeuk, linux-f2fs-devel, linux-kernel, syzkaller-bugs Hi Dan, On 2020-9-25 18:57, Dan Carpenter wrote: > On Fri, Sep 25, 2020 at 05:06:33PM +0800, Chao Yu wrote: >> Hi, >> >> I don't see any problem here, thanks for your report. :) >> > > I bet the uninitialize value is because "max_depth" is zero. I agree with you, thanks for the hint. :) Thanks, > > > 352 struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, > 353 const struct f2fs_filename *fname, > 354 struct page **res_page) > ^^^^^^^^ > The stack trace says this isn't initialized. > > 355 { > 356 unsigned long npages = dir_blocks(dir); > 357 struct f2fs_dir_entry *de = NULL; > 358 unsigned int max_depth; > 359 unsigned int level; > 360 > 361 if (f2fs_has_inline_dentry(dir)) { > 362 *res_page = NULL; > 363 de = f2fs_find_in_inline_dir(dir, fname, res_page); > 364 goto out; > 365 } > 366 > 367 if (npages == 0) { > 368 *res_page = NULL; > 369 goto out; > 370 } > 371 > 372 max_depth = F2FS_I(dir)->i_current_depth; > 373 if (unlikely(max_depth > MAX_DIR_HASH_DEPTH)) { > 374 f2fs_warn(F2FS_I_SB(dir), "Corrupted max_depth of %lu: %u", > 375 dir->i_ino, max_depth); > 376 max_depth = MAX_DIR_HASH_DEPTH; > 377 f2fs_i_depth_write(dir, max_depth); > 378 } > 379 > 380 for (level = 0; level < max_depth; level++) { > ^^^^^^^^^^^^^^^^^ > If "max_depth" is zero, then we never enter this loop. > > 381 *res_page = NULL; > 382 de = find_in_level(dir, level, fname, res_page); > 383 if (de || IS_ERR(*res_page)) > 384 break; > 385 } > 386 out: > 387 /* This is to increase the speed of f2fs_create */ > 388 if (!de) > 389 F2FS_I(dir)->task = current; > 390 return de; > > Which means that we return a NULL "de" and "*res_page" is uninitialized > and that matches what syzbot found throug runtime testing. > > 391 } > > regards, > dan carpenter > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [f2fs-dev] KMSAN: uninit-value in f2fs_lookup 2020-09-25 9:06 ` [f2fs-dev] " Chao Yu 2020-09-25 10:57 ` Dan Carpenter @ 2020-09-25 16:38 ` Eric Biggers 2020-09-25 16:45 ` Eric Biggers 1 sibling, 1 reply; 7+ messages in thread From: Eric Biggers @ 2020-09-25 16:38 UTC (permalink / raw) To: Chao Yu Cc: syzbot, chao, glider, jaegeuk, linux-f2fs-devel, linux-kernel, syzkaller-bugs On Fri, Sep 25, 2020 at 05:06:33PM +0800, Chao Yu wrote: > Hi, > > I don't see any problem here, thanks for your report. :) > > Thanks, What about if max_depth == 0 in __f2fs_find_entry()? Then __f2fs_find_entry() would return NULL without initializing *res_page. A fix could be: diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 069f498af1e3..ceb4431b5669 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -357,16 +357,15 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, unsigned int max_depth; unsigned int level; + *res_page = NULL; + if (f2fs_has_inline_dentry(dir)) { - *res_page = NULL; de = f2fs_find_in_inline_dir(dir, fname, res_page); goto out; } - if (npages == 0) { - *res_page = NULL; + if (npages == 0) goto out; - } max_depth = F2FS_I(dir)->i_current_depth; if (unlikely(max_depth > MAX_DIR_HASH_DEPTH)) { @@ -377,7 +376,6 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, } for (level = 0; level < max_depth; level++) { - *res_page = NULL; de = find_in_level(dir, level, fname, res_page); if (de || IS_ERR(*res_page)) break; ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [f2fs-dev] KMSAN: uninit-value in f2fs_lookup 2020-09-25 16:38 ` Eric Biggers @ 2020-09-25 16:45 ` Eric Biggers 2020-09-25 23:17 ` Chao Yu 0 siblings, 1 reply; 7+ messages in thread From: Eric Biggers @ 2020-09-25 16:45 UTC (permalink / raw) To: Chao Yu Cc: syzbot, chao, glider, jaegeuk, linux-f2fs-devel, linux-kernel, syzkaller-bugs On Fri, Sep 25, 2020 at 09:38:19AM -0700, Eric Biggers wrote: > On Fri, Sep 25, 2020 at 05:06:33PM +0800, Chao Yu wrote: > > Hi, > > > > I don't see any problem here, thanks for your report. :) > > > > Thanks, > > What about if max_depth == 0 in __f2fs_find_entry()? Then __f2fs_find_entry() > would return NULL without initializing *res_page. ... and I now see Dan Carpenter already pointed this out. I was a bit late! - Eric ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [f2fs-dev] KMSAN: uninit-value in f2fs_lookup 2020-09-25 16:45 ` Eric Biggers @ 2020-09-25 23:17 ` Chao Yu 0 siblings, 0 replies; 7+ messages in thread From: Chao Yu @ 2020-09-25 23:17 UTC (permalink / raw) To: Eric Biggers, Chao Yu Cc: syzbot, glider, jaegeuk, linux-f2fs-devel, linux-kernel, syzkaller-bugs On 2020-9-26 0:45, Eric Biggers wrote: > On Fri, Sep 25, 2020 at 09:38:19AM -0700, Eric Biggers wrote: >> On Fri, Sep 25, 2020 at 05:06:33PM +0800, Chao Yu wrote: >>> Hi, >>> >>> I don't see any problem here, thanks for your report. :) >>> >>> Thanks, >> >> What about if max_depth == 0 in __f2fs_find_entry()? Then __f2fs_find_entry() >> would return NULL without initializing *res_page. > > ... and I now see Dan Carpenter already pointed this out. I was a bit late! Thanks for your check as well. :) Thanks, > > - Eric > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-25 23:17 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-09-25 5:18 KMSAN: uninit-value in f2fs_lookup syzbot 2020-09-25 9:06 ` [f2fs-dev] " Chao Yu 2020-09-25 10:57 ` Dan Carpenter 2020-09-25 15:01 ` Chao Yu 2020-09-25 16:38 ` Eric Biggers 2020-09-25 16:45 ` Eric Biggers 2020-09-25 23:17 ` Chao Yu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox