public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* KASAN: use-after-free Read in mnt_warn_timestamp_expiry
@ 2019-10-17  1:42 syzbot
  2019-10-17  1:47 ` Eric Biggers
  0 siblings, 1 reply; 6+ messages in thread
From: syzbot @ 2019-10-17  1:42 UTC (permalink / raw)
  To: akpm, deepa.kernel, hch, jlayton, linux-fsdevel, linux-kernel,
	lkundrak, syzkaller-bugs, tklauser, trond.myklebust, viro

Hello,

syzbot found the following crash on:

HEAD commit:    3b1f00ac Merge tag 'for_linus' of git://git.kernel.org/pub..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=137ae2bb600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=f0a8b0a0736a2ac1
dashboard link: https://syzkaller.appspot.com/bug?extid=76a43f2b4d34cfc53548
compiler:       clang version 9.0.0 (/home/glider/llvm/clang  
80fee25776c2fb61e74c1ecb1a523375c2500b69)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=10dde730e00000

The bug was bisected to:

commit 452c2779410a03ac0c6be0a8a91c83aa80bdd7e5
Author: Deepa Dinamani <deepa.kernel@gmail.com>
Date:   Fri Mar 8 20:40:03 2019 +0000

     fs: sysv: Initialize filesystem timestamp ranges

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=13c6e2bb600000
final crash:    https://syzkaller.appspot.com/x/report.txt?x=1026e2bb600000
console output: https://syzkaller.appspot.com/x/log.txt?x=17c6e2bb600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+76a43f2b4d34cfc53548@syzkaller.appspotmail.com
Fixes: 452c2779410a ("fs: sysv: Initialize filesystem timestamp ranges")

==================================================================
BUG: KASAN: use-after-free in mnt_warn_timestamp_expiry+0x4a/0x250  
fs/namespace.c:2471
Read of size 8 at addr ffff888099937328 by task syz-executor.1/18510

CPU: 0 PID: 18510 Comm: syz-executor.1 Not tainted 5.4.0-rc3+ #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+0x1d8/0x2f8 lib/dump_stack.c:113
  print_address_description+0x75/0x5c0 mm/kasan/report.c:374
  __kasan_report+0x14b/0x1c0 mm/kasan/report.c:506
  kasan_report+0x26/0x50 mm/kasan/common.c:634
  __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
  mnt_warn_timestamp_expiry+0x4a/0x250 fs/namespace.c:2471
  do_new_mount_fc fs/namespace.c:2773 [inline]
  do_new_mount fs/namespace.c:2825 [inline]
  do_mount+0x2160/0x2510 fs/namespace.c:3143
  ksys_mount+0xcc/0x100 fs/namespace.c:3352
  __do_sys_mount fs/namespace.c:3366 [inline]
  __se_sys_mount fs/namespace.c:3363 [inline]
  __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3363
  do_syscall_64+0xf7/0x1c0 arch/x86/entry/common.c:290
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459a59
Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 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 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f1f46735c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 0000000000459a59
RDX: 0000000020000a40 RSI: 00000000200005c0 RDI: 0000000000000000
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f1f467366d4
R13: 00000000004c62a4 R14: 00000000004db438 R15: 00000000ffffffff

Allocated by task 18510:
  save_stack mm/kasan/common.c:69 [inline]
  set_track mm/kasan/common.c:77 [inline]
  __kasan_kmalloc+0x11c/0x1b0 mm/kasan/common.c:510
  kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:518
  slab_post_alloc_hook mm/slab.h:584 [inline]
  slab_alloc mm/slab.c:3319 [inline]
  kmem_cache_alloc+0x1f5/0x2e0 mm/slab.c:3483
  kmem_cache_zalloc include/linux/slab.h:680 [inline]
  alloc_vfsmnt+0x27/0x470 fs/namespace.c:177
  vfs_create_mount+0x87/0x440 fs/namespace.c:940
  do_new_mount_fc fs/namespace.c:2763 [inline]
  do_new_mount fs/namespace.c:2825 [inline]
  do_mount+0x1ee0/0x2510 fs/namespace.c:3143
  ksys_mount+0xcc/0x100 fs/namespace.c:3352
  __do_sys_mount fs/namespace.c:3366 [inline]
  __se_sys_mount fs/namespace.c:3363 [inline]
  __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3363
  do_syscall_64+0xf7/0x1c0 arch/x86/entry/common.c:290
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 16:
  save_stack mm/kasan/common.c:69 [inline]
  set_track mm/kasan/common.c:77 [inline]
  kasan_set_free_info mm/kasan/common.c:332 [inline]
  __kasan_slab_free+0x12a/0x1e0 mm/kasan/common.c:471
  kasan_slab_free+0xe/0x10 mm/kasan/common.c:480
  __cache_free mm/slab.c:3425 [inline]
  kmem_cache_free+0x81/0xf0 mm/slab.c:3693
  free_vfsmnt fs/namespace.c:554 [inline]
  delayed_free_vfsmnt+0x74/0x80 fs/namespace.c:559
  __rcu_reclaim kernel/rcu/rcu.h:222 [inline]
  rcu_do_batch kernel/rcu/tree.c:2157 [inline]
  rcu_core+0x843/0x1050 kernel/rcu/tree.c:2377
  rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2386
  __do_softirq+0x333/0x7c4 arch/x86/include/asm/paravirt.h:766

The buggy address belongs to the object at ffff888099937300
  which belongs to the cache mnt_cache of size 312
The buggy address is located 40 bytes inside of
  312-byte region [ffff888099937300, ffff888099937438)
The buggy address belongs to the page:
page:ffffea0002664dc0 refcount:1 mapcount:0 mapping:ffff8880aa5a9a80  
index:0xffff888099937180
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea000285d4c8 ffffea00026ab308 ffff8880aa5a9a80
raw: ffff888099937180 ffff888099937000 0000000100000008 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
  ffff888099937200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
  ffff888099937280: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
> ffff888099937300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                   ^
  ffff888099937380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
  ffff888099937400: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
==================================================================


---
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 syzkaller@googlegroups.com.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: KASAN: use-after-free Read in mnt_warn_timestamp_expiry
  2019-10-17  1:42 KASAN: use-after-free Read in mnt_warn_timestamp_expiry syzbot
@ 2019-10-17  1:47 ` Eric Biggers
  2019-10-17  1:58   ` Al Viro
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2019-10-17  1:47 UTC (permalink / raw)
  To: syzbot
  Cc: akpm, deepa.kernel, hch, jlayton, linux-fsdevel, linux-kernel,
	lkundrak, syzkaller-bugs, tklauser, trond.myklebust, viro

On Wed, Oct 16, 2019 at 06:42:11PM -0700, syzbot wrote:
> ==================================================================
> BUG: KASAN: use-after-free in mnt_warn_timestamp_expiry+0x4a/0x250
> fs/namespace.c:2471
> Read of size 8 at addr ffff888099937328 by task syz-executor.1/18510
> 

Looks like a duplicate of this:

#syz dup: KASAN: use-after-free Read in do_mount

See the existing thread and proposed fix here:
https://lkml.kernel.org/linux-fsdevel/000000000000805e5505945a234b@google.com/T/#u

- Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: KASAN: use-after-free Read in mnt_warn_timestamp_expiry
  2019-10-17  1:47 ` Eric Biggers
@ 2019-10-17  1:58   ` Al Viro
  2019-10-17  2:27     ` Eric Biggers
  0 siblings, 1 reply; 6+ messages in thread
From: Al Viro @ 2019-10-17  1:58 UTC (permalink / raw)
  To: syzbot, akpm, deepa.kernel, hch, jlayton, linux-fsdevel,
	linux-kernel, lkundrak, syzkaller-bugs, tklauser, trond.myklebust

On Wed, Oct 16, 2019 at 06:47:55PM -0700, Eric Biggers wrote:
> On Wed, Oct 16, 2019 at 06:42:11PM -0700, syzbot wrote:
> > ==================================================================
> > BUG: KASAN: use-after-free in mnt_warn_timestamp_expiry+0x4a/0x250
> > fs/namespace.c:2471
> > Read of size 8 at addr ffff888099937328 by task syz-executor.1/18510
> > 
> 
> Looks like a duplicate of this:
> 
> #syz dup: KASAN: use-after-free Read in do_mount
> 
> See the existing thread and proposed fix here:
> https://lkml.kernel.org/linux-fsdevel/000000000000805e5505945a234b@google.com/T/#u

FWIW, I'd go with your "move mnt_warn_timestamp_expiry() up".  However,
I'd probably turn the message into something like
	foofs filesystem getting mounted at /mnt/barf supports...
And s/mounted/reconfigured/ if mnt_has_parent(mnt) is already true.

Objections?

Al, currently experiencing the joy of being ears-deep in 5 different shitpiles
simultaneously...

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: KASAN: use-after-free Read in mnt_warn_timestamp_expiry
  2019-10-17  1:58   ` Al Viro
@ 2019-10-17  2:27     ` Eric Biggers
  2019-10-17  2:37       ` Al Viro
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2019-10-17  2:27 UTC (permalink / raw)
  To: Al Viro
  Cc: syzbot, akpm, deepa.kernel, hch, jlayton, linux-fsdevel,
	linux-kernel, lkundrak, syzkaller-bugs, tklauser, trond.myklebust

On Thu, Oct 17, 2019 at 02:58:53AM +0100, Al Viro wrote:
> On Wed, Oct 16, 2019 at 06:47:55PM -0700, Eric Biggers wrote:
> > On Wed, Oct 16, 2019 at 06:42:11PM -0700, syzbot wrote:
> > > ==================================================================
> > > BUG: KASAN: use-after-free in mnt_warn_timestamp_expiry+0x4a/0x250
> > > fs/namespace.c:2471
> > > Read of size 8 at addr ffff888099937328 by task syz-executor.1/18510
> > > 
> > 
> > Looks like a duplicate of this:
> > 
> > #syz dup: KASAN: use-after-free Read in do_mount
> > 
> > See the existing thread and proposed fix here:
> > https://lkml.kernel.org/linux-fsdevel/000000000000805e5505945a234b@google.com/T/#u
> 
> FWIW, I'd go with your "move mnt_warn_timestamp_expiry() up".  However,
> I'd probably turn the message into something like
> 	foofs filesystem getting mounted at /mnt/barf supports...
> And s/mounted/reconfigured/ if mnt_has_parent(mnt) is already true.
> 
> Objections?
> 

How about the following?

	pr_warn("%s filesystem being %s at %s supports timestamps until %04ld (0x%llx)\n",
		sb->s_type->name,
		is_mounted(mnt) ? "remounted" : "mounted",
		mntpath,
		tm.tm_year+1900, (unsigned long long)sb->s_time_max);

I think more people would understand "remounted" than "reconfigured".  Also,
is_mounted(mnt) seems like a better choice than mnt_has_parent(real_mount(mnt)).

- Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: KASAN: use-after-free Read in mnt_warn_timestamp_expiry
  2019-10-17  2:27     ` Eric Biggers
@ 2019-10-17  2:37       ` Al Viro
  2019-10-17  2:50         ` Eric Biggers
  0 siblings, 1 reply; 6+ messages in thread
From: Al Viro @ 2019-10-17  2:37 UTC (permalink / raw)
  To: syzbot, akpm, deepa.kernel, hch, jlayton, linux-fsdevel,
	linux-kernel, lkundrak, syzkaller-bugs, tklauser, trond.myklebust

On Wed, Oct 16, 2019 at 07:27:05PM -0700, Eric Biggers wrote:

> How about the following?
> 
> 	pr_warn("%s filesystem being %s at %s supports timestamps until %04ld (0x%llx)\n",
> 		sb->s_type->name,
> 		is_mounted(mnt) ? "remounted" : "mounted",
> 		mntpath,
> 		tm.tm_year+1900, (unsigned long long)sb->s_time_max);
> 
> I think more people would understand "remounted" than "reconfigured".  Also,
> is_mounted(mnt) seems like a better choice than mnt_has_parent(real_mount(mnt)).

Works for me(tm).  Care to fold that into your patch and resend?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: KASAN: use-after-free Read in mnt_warn_timestamp_expiry
  2019-10-17  2:37       ` Al Viro
@ 2019-10-17  2:50         ` Eric Biggers
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Biggers @ 2019-10-17  2:50 UTC (permalink / raw)
  To: Al Viro
  Cc: syzbot, akpm, deepa.kernel, hch, jlayton, linux-fsdevel,
	linux-kernel, lkundrak, syzkaller-bugs, tklauser, trond.myklebust

On Thu, Oct 17, 2019 at 03:37:35AM +0100, Al Viro wrote:
> On Wed, Oct 16, 2019 at 07:27:05PM -0700, Eric Biggers wrote:
> 
> > How about the following?
> > 
> > 	pr_warn("%s filesystem being %s at %s supports timestamps until %04ld (0x%llx)\n",
> > 		sb->s_type->name,
> > 		is_mounted(mnt) ? "remounted" : "mounted",
> > 		mntpath,
> > 		tm.tm_year+1900, (unsigned long long)sb->s_time_max);
> > 
> > I think more people would understand "remounted" than "reconfigured".  Also,
> > is_mounted(mnt) seems like a better choice than mnt_has_parent(real_mount(mnt)).
> 
> Works for me(tm).  Care to fold that into your patch and resend?
> 

Sent: https://lkml.kernel.org/linux-fsdevel/20191017024814.61980-1-ebiggers@kernel.org/T/#u

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-17  2:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-17  1:42 KASAN: use-after-free Read in mnt_warn_timestamp_expiry syzbot
2019-10-17  1:47 ` Eric Biggers
2019-10-17  1:58   ` Al Viro
2019-10-17  2:27     ` Eric Biggers
2019-10-17  2:37       ` Al Viro
2019-10-17  2:50         ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox