linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* KASAN: use-after-free Read in getname_kernel
@ 2018-06-11  5:45 syzbot
  2018-06-11 17:38 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: syzbot @ 2018-06-11  5:45 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel, syzkaller-bugs, viro

Hello,

syzbot found the following crash on:

HEAD commit:    3ca24ce9ff76 Merge branch 'proc-cmdline'
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15ed37d7800000
kernel config:  https://syzkaller.appspot.com/x/.config?x=314f2150f36c16ca
dashboard link: https://syzkaller.appspot.com/bug?extid=abf707d7ccbb3244f34e
compiler:       gcc (GCC) 8.0.1 20180413 (experimental)

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

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

==================================================================
BUG: KASAN: use-after-free in memcpy include/linux/string.h:345 [inline]
BUG: KASAN: use-after-free in getname_kernel+0x123/0x370 fs/namei.c:241
Read of size 11 at addr ffff8801d8053310 by task syz-executor5/15925

CPU: 0 PID: 15925 Comm: syz-executor5 Not tainted 4.17.0+ #94
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+0x1b9/0x294 lib/dump_stack.c:113
  print_address_description+0x6c/0x20b mm/kasan/report.c:256
  kasan_report_error mm/kasan/report.c:354 [inline]
  kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
  check_memory_region_inline mm/kasan/kasan.c:260 [inline]
  check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
  memcpy+0x23/0x50 mm/kasan/kasan.c:302
  memcpy include/linux/string.h:345 [inline]
  getname_kernel+0x123/0x370 fs/namei.c:241
  kern_path+0x1e/0x40 fs/namei.c:2410
  lookup_bdev+0xfa/0x240 fs/block_dev.c:2084
  blkdev_get_by_path+0x1f/0xe0 fs/block_dev.c:1687
  btrfs_get_bdev_and_sb+0x38/0x300 fs/btrfs/volumes.c:392
  btrfs_open_one_device fs/btrfs/volumes.c:695 [inline]
  open_fs_devices+0x6a5/0xc60 fs/btrfs/volumes.c:1112
  btrfs_open_devices+0xc0/0xd0 fs/btrfs/volumes.c:1155
  btrfs_mount_root+0x91f/0x1e70 fs/btrfs/super.c:1568
  mount_fs+0xae/0x328 fs/super.c:1277
  vfs_kern_mount.part.34+0xd4/0x4d0 fs/namespace.c:1037
  vfs_kern_mount+0x40/0x60 fs/namespace.c:1027
  btrfs_mount+0x4a1/0x213e fs/btrfs/super.c:1661
  mount_fs+0xae/0x328 fs/super.c:1277
  vfs_kern_mount.part.34+0xd4/0x4d0 fs/namespace.c:1037
  vfs_kern_mount fs/namespace.c:1027 [inline]
  do_new_mount fs/namespace.c:2518 [inline]
  do_mount+0x564/0x30b0 fs/namespace.c:2848
  ksys_mount+0x12d/0x140 fs/namespace.c:3064
  __do_sys_mount fs/namespace.c:3078 [inline]
  __se_sys_mount fs/namespace.c:3075 [inline]
  __x64_sys_mount+0xbe/0x150 fs/namespace.c:3075
  do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45842a
Code: b8 a6 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 dd 8f fb ff c3 66 2e 0f  
1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 ba 8f fb ff c3 66 0f 1f 84 00 00 00 00 00
RSP: 002b:00007fe10e408ba8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000020000080 RCX: 000000000045842a
RDX: 0000000020000080 RSI: 0000000020000100 RDI: 00007fe10e408bf0
RBP: 0000000000000001 R08: 0000000020000240 R09: 0000000020000080
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000014
R13: 0000000000000001 R14: 00000000004d2bc0 R15: 0000000000000000

Allocated by task 15908:
  save_stack+0x43/0xd0 mm/kasan/kasan.c:448
  set_track mm/kasan/kasan.c:460 [inline]
  kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
  __do_kmalloc mm/slab.c:3718 [inline]
  __kmalloc+0x14e/0x760 mm/slab.c:3727
  kmalloc include/linux/slab.h:518 [inline]
  kzalloc include/linux/slab.h:706 [inline]
  rcu_string_strdup fs/btrfs/rcu-string.h:17 [inline]
  btrfs_prepare_close_one_device fs/btrfs/volumes.c:1031 [inline]
  close_fs_devices+0x497/0xfa0 fs/btrfs/volumes.c:1052
  btrfs_close_devices+0x29/0x150 fs/btrfs/volumes.c:1085
  open_ctree+0x589/0x7898 fs/btrfs/disk-io.c:3358
  btrfs_fill_super fs/btrfs/super.c:1202 [inline]
  btrfs_mount_root+0x16df/0x1e70 fs/btrfs/super.c:1593
  mount_fs+0xae/0x328 fs/super.c:1277
  vfs_kern_mount.part.34+0xd4/0x4d0 fs/namespace.c:1037
  vfs_kern_mount+0x40/0x60 fs/namespace.c:1027
  btrfs_mount+0x4a1/0x213e fs/btrfs/super.c:1661
  mount_fs+0xae/0x328 fs/super.c:1277
  vfs_kern_mount.part.34+0xd4/0x4d0 fs/namespace.c:1037
  vfs_kern_mount fs/namespace.c:1027 [inline]
  do_new_mount fs/namespace.c:2518 [inline]
  do_mount+0x564/0x30b0 fs/namespace.c:2848
  ksys_mount+0x12d/0x140 fs/namespace.c:3064
  __do_sys_mount fs/namespace.c:3078 [inline]
  __se_sys_mount fs/namespace.c:3075 [inline]
  __x64_sys_mount+0xbe/0x150 fs/namespace.c:3075
  do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 15922:
  save_stack+0x43/0xd0 mm/kasan/kasan.c:448
  set_track mm/kasan/kasan.c:460 [inline]
  __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
  kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
  __cache_free mm/slab.c:3498 [inline]
  kfree+0xd9/0x260 mm/slab.c:3813
  __rcu_reclaim kernel/rcu/rcu.h:173 [inline]
  rcu_do_batch kernel/rcu/tree.c:2558 [inline]
  invoke_rcu_callbacks kernel/rcu/tree.c:2818 [inline]
  __rcu_process_callbacks kernel/rcu/tree.c:2785 [inline]
  rcu_process_callbacks+0xfc5/0x1760 kernel/rcu/tree.c:2802
  __do_softirq+0x2e0/0xaf5 kernel/softirq.c:284

The buggy address belongs to the object at ffff8801d8053300
  which belongs to the cache kmalloc-32 of size 32
The buggy address is located 16 bytes inside of
  32-byte region [ffff8801d8053300, ffff8801d8053320)
The buggy address belongs to the page:
page:ffffea00076014c0 count:1 mapcount:0 mapping:ffff8801da8001c0  
index:0xffff8801d8053fc1
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea00075f2f08 ffffea00075a9a08 ffff8801da8001c0
raw: ffff8801d8053fc1 ffff8801d8053000 0000000100000011 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
  ffff8801d8053200: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
  ffff8801d8053280: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
> ffff8801d8053300: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
                          ^
  ffff8801d8053380: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
  ffff8801d8053400: fb fb fb fb fc fc fc fc fb fb fb fb 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#bug-status-tracking for how to communicate with  
syzbot.

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

* Re: KASAN: use-after-free Read in getname_kernel
  2018-06-11  5:45 KASAN: use-after-free Read in getname_kernel syzbot
@ 2018-06-11 17:38 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2018-06-11 17:38 UTC (permalink / raw)
  To: syzbot; +Cc: linux-fsdevel, linux-kernel, syzkaller-bugs, viro, linux-btrfs

On Sun, Jun 10, 2018 at 10:45:02PM -0700, syzbot wrote:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:    3ca24ce9ff76 Merge branch 'proc-cmdline'
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=15ed37d7800000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=314f2150f36c16ca
> dashboard link: https://syzkaller.appspot.com/bug?extid=abf707d7ccbb3244f34e
> compiler:       gcc (GCC) 8.0.1 20180413 (experimental)
> 
> Unfortunately, I don't have any reproducer for this crash yet.
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+abf707d7ccbb3244f34e@syzkaller.appspotmail.com
> 
> ==================================================================
> BUG: KASAN: use-after-free in memcpy include/linux/string.h:345 [inline]
> BUG: KASAN: use-after-free in getname_kernel+0x123/0x370 fs/namei.c:241
> Read of size 11 at addr ffff8801d8053310 by task syz-executor5/15925
> 
> CPU: 0 PID: 15925 Comm: syz-executor5 Not tainted 4.17.0+ #94
> 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+0x1b9/0x294 lib/dump_stack.c:113
>  print_address_description+0x6c/0x20b mm/kasan/report.c:256
>  kasan_report_error mm/kasan/report.c:354 [inline]
>  kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
>  check_memory_region_inline mm/kasan/kasan.c:260 [inline]
>  check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
>  memcpy+0x23/0x50 mm/kasan/kasan.c:302
>  memcpy include/linux/string.h:345 [inline]
>  getname_kernel+0x123/0x370 fs/namei.c:241
>  kern_path+0x1e/0x40 fs/namei.c:2410
>  lookup_bdev+0xfa/0x240 fs/block_dev.c:2084
>  blkdev_get_by_path+0x1f/0xe0 fs/block_dev.c:1687
>  btrfs_get_bdev_and_sb+0x38/0x300 fs/btrfs/volumes.c:392
>  btrfs_open_one_device fs/btrfs/volumes.c:695 [inline]
>  open_fs_devices+0x6a5/0xc60 fs/btrfs/volumes.c:1112
>  btrfs_open_devices+0xc0/0xd0 fs/btrfs/volumes.c:1155

I think it's another manifestation of the bug syzbot reported against
btrfs_open_devices

https://lkml.kernel.org/r/000000000000832e70056df8fb38@google.com

Currently proposed fix is to revert
542c5908abfe84f7b4c1717492ecc92ea0ea328d, that's going to be merged post
rc1.

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

end of thread, other threads:[~2018-06-11 17:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11  5:45 KASAN: use-after-free Read in getname_kernel syzbot
2018-06-11 17:38 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).