Re: [syzbot] KASAN: use-after-free Read in kill_pending_fw_fallback_reqs

2021-03-19 Thread Dmitry Vyukov
On Fri, Mar 19, 2021 at 7:08 AM Hillf Danton  wrote:
>
> On Thu, 18 Mar 2021 08:10:19 -0700
> > Hello,
> >
> > syzbot found the following issue on:
> >
> > HEAD commit:6417f031 module: remove never implemented MODULE_SUPPORTED..
> > git tree:   upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=16293a7cd0
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=ab2c8a4eaedddecd
> > dashboard link: https://syzkaller.appspot.com/bug?extid=6e23e12624dbacf657bc
> >
> > Unfortunately, I don't have any reproducer for this issue yet.
>
> Looks like the same cause as
> Reported-by: syzbot+de271708674e20930...@syzkaller.appspotmail.com

Hi Hillf,

Let's tell syzbot about this then:

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

Please see http://bit.do/syzbot#communication-with-syzbot for details
on communicating with syzbot.
(and please don't CC more than 1 syzbot+HASH emails, it may cause
havoc, syzbot won't be able to figure out what bug people are talking
about).


> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+6e23e12624dbacf65...@syzkaller.appspotmail.com
> >
> > ==
> > BUG: KASAN: use-after-free in kill_pending_fw_fallback_reqs+0x2fb/0x370 
> > drivers/base/firmware_loader/fallback.c:116
> > Read of size 8 at addr 8880757caac0 by task syz-executor.1/14981
> >
> > CPU: 0 PID: 14981 Comm: syz-executor.1 Not tainted 5.12.0-rc3-syzkaller #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
> > Google 01/01/2011
> > Call Trace:
> >  __dump_stack lib/dump_stack.c:79 [inline]
> >  dump_stack+0x141/0x1d7 lib/dump_stack.c:120
> >  print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:232
> >  __kasan_report mm/kasan/report.c:399 [inline]
> >  kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:416
> >  kill_pending_fw_fallback_reqs+0x2fb/0x370 
> > drivers/base/firmware_loader/fallback.c:116
> >  fw_pm_notify+0xa2/0x150 drivers/base/firmware_loader/main.c:1448
> >  notifier_call_chain+0xb5/0x200 kernel/notifier.c:83
> >  notifier_call_chain_robust kernel/notifier.c:118 [inline]
> >  blocking_notifier_call_chain_robust kernel/notifier.c:302 [inline]
> >  blocking_notifier_call_chain_robust+0xc4/0x160 kernel/notifier.c:290
> >  pm_notifier_call_chain_robust+0x26/0x60 kernel/power/main.c:87
> >  snapshot_open+0x190/0x2a0 kernel/power/user.c:75
> >  misc_open+0x372/0x4a0 drivers/char/misc.c:141
> >  chrdev_open+0x266/0x770 fs/char_dev.c:414
> >  do_dentry_open+0x4b9/0x11b0 fs/open.c:826
> >  do_open fs/namei.c:3365 [inline]
> >  path_openat+0x1c0e/0x27e0 fs/namei.c:3498
> >  do_filp_open+0x17e/0x3c0 fs/namei.c:3525
> >  do_sys_openat2+0x16d/0x420 fs/open.c:1187
> >  do_sys_open fs/open.c:1203 [inline]
> >  __do_sys_openat fs/open.c:1219 [inline]
> >  __se_sys_openat fs/open.c:1214 [inline]
> >  __x64_sys_openat+0x13f/0x1f0 fs/open.c:1214
> >  do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
> >  entry_SYSCALL_64_after_hwframe+0x44/0xae
> > RIP: 0033:0x465f69
> > Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 bc ff ff ff f7 d8 64 89 01 48
> > RSP: 002b:7f9819e12188 EFLAGS: 0246 ORIG_RAX: 0101
> > RAX: ffda RBX: 0056bf60 RCX: 00465f69
> > RDX:  RSI: 2ac0 RDI: ff9c
> > RBP: 004bfa8f R08:  R09: 
> > R10:  R11: 0246 R12: 0056bf60
> > R13: 7ffd557c11df R14: 7f9819e12300 R15: 00022000
> >
> > Allocated by task 13418:
> >  kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
> >  kasan_set_track mm/kasan/common.c:46 [inline]
> >  set_alloc_info mm/kasan/common.c:427 [inline]
> >  kasan_kmalloc mm/kasan/common.c:506 [inline]
> >  kasan_kmalloc mm/kasan/common.c:465 [inline]
> >  __kasan_kmalloc+0x99/0xc0 mm/kasan/common.c:515
> >  kmalloc include/linux/slab.h:554 [inline]
> >  kzalloc include/linux/slab.h:684 [inline]
> >  __allocate_fw_priv drivers/base/firmware_loader/main.c:186 [inline]
> >  alloc_lookup_fw_priv drivers/base/firmware_loader/main.c:250 [inline]
> >  _request_firmware_prepare drivers/base/firmware_loader/main.c:744 [inline]
> >  _request_firmware+0x2de/0xe80 drivers/base/firmware_loader/main.c:806
> >  request_firmware+0x32/0x50 drivers/base/firmware_loader/main.c:875
> >  reg_reload_regdb+0x7a/0x240 net/wireless/reg.c:1095
> >  genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:739
> >  genl_family_rcv_msg net/netlink/genetlink.c:783 [inline]
> >  genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:800
> >  netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2502
> >  genl_rcv+0x24/0x40 net/netlink/genetlink.c:811
> >  netlink_unicast_kernel net/netlink/af_netlink.c:1312 

[syzbot] KASAN: use-after-free Read in kill_pending_fw_fallback_reqs

2021-03-18 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:6417f031 module: remove never implemented MODULE_SUPPORTED..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16293a7cd0
kernel config:  https://syzkaller.appspot.com/x/.config?x=ab2c8a4eaedddecd
dashboard link: https://syzkaller.appspot.com/bug?extid=6e23e12624dbacf657bc

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+6e23e12624dbacf65...@syzkaller.appspotmail.com

==
BUG: KASAN: use-after-free in kill_pending_fw_fallback_reqs+0x2fb/0x370 
drivers/base/firmware_loader/fallback.c:116
Read of size 8 at addr 8880757caac0 by task syz-executor.1/14981

CPU: 0 PID: 14981 Comm: syz-executor.1 Not tainted 5.12.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x141/0x1d7 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:232
 __kasan_report mm/kasan/report.c:399 [inline]
 kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:416
 kill_pending_fw_fallback_reqs+0x2fb/0x370 
drivers/base/firmware_loader/fallback.c:116
 fw_pm_notify+0xa2/0x150 drivers/base/firmware_loader/main.c:1448
 notifier_call_chain+0xb5/0x200 kernel/notifier.c:83
 notifier_call_chain_robust kernel/notifier.c:118 [inline]
 blocking_notifier_call_chain_robust kernel/notifier.c:302 [inline]
 blocking_notifier_call_chain_robust+0xc4/0x160 kernel/notifier.c:290
 pm_notifier_call_chain_robust+0x26/0x60 kernel/power/main.c:87
 snapshot_open+0x190/0x2a0 kernel/power/user.c:75
 misc_open+0x372/0x4a0 drivers/char/misc.c:141
 chrdev_open+0x266/0x770 fs/char_dev.c:414
 do_dentry_open+0x4b9/0x11b0 fs/open.c:826
 do_open fs/namei.c:3365 [inline]
 path_openat+0x1c0e/0x27e0 fs/namei.c:3498
 do_filp_open+0x17e/0x3c0 fs/namei.c:3525
 do_sys_openat2+0x16d/0x420 fs/open.c:1187
 do_sys_open fs/open.c:1203 [inline]
 __do_sys_openat fs/open.c:1219 [inline]
 __se_sys_openat fs/open.c:1214 [inline]
 __x64_sys_openat+0x13f/0x1f0 fs/open.c:1214
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x465f69
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:7f9819e12188 EFLAGS: 0246 ORIG_RAX: 0101
RAX: ffda RBX: 0056bf60 RCX: 00465f69
RDX:  RSI: 2ac0 RDI: ff9c
RBP: 004bfa8f R08:  R09: 
R10:  R11: 0246 R12: 0056bf60
R13: 7ffd557c11df R14: 7f9819e12300 R15: 00022000

Allocated by task 13418:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:427 [inline]
 kasan_kmalloc mm/kasan/common.c:506 [inline]
 kasan_kmalloc mm/kasan/common.c:465 [inline]
 __kasan_kmalloc+0x99/0xc0 mm/kasan/common.c:515
 kmalloc include/linux/slab.h:554 [inline]
 kzalloc include/linux/slab.h:684 [inline]
 __allocate_fw_priv drivers/base/firmware_loader/main.c:186 [inline]
 alloc_lookup_fw_priv drivers/base/firmware_loader/main.c:250 [inline]
 _request_firmware_prepare drivers/base/firmware_loader/main.c:744 [inline]
 _request_firmware+0x2de/0xe80 drivers/base/firmware_loader/main.c:806
 request_firmware+0x32/0x50 drivers/base/firmware_loader/main.c:875
 reg_reload_regdb+0x7a/0x240 net/wireless/reg.c:1095
 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:739
 genl_family_rcv_msg net/netlink/genetlink.c:783 [inline]
 genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:800
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2502
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:811
 netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338
 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927
 sock_sendmsg_nosec net/socket.c:654 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:674
 sys_sendmsg+0x6e8/0x810 net/socket.c:2350
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2404
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2433
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at 8880757caa00
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 192 bytes inside of
 256-byte region [8880757caa00, 8880757cab00)
The buggy address belongs to the page:
page:ea0001d5f280 refcount:1 mapcount:0 mapping: 
index:0x8880757caa00 pfn:0x757ca
head:ea0001d5f280 order:1 compound_mapcount:0
flags: