KASAN: use-after-free Read in nbd_release

11 views
Skip to first unread message

syzbot

unread,
Feb 20, 2021, 6:32:20 AM2/20/21
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 29c52025 Linux 4.14.221
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1771f79cd00000
kernel config: https://syzkaller.appspot.com/x/.config?x=83f668f81cfc5600
dashboard link: https://syzkaller.appspot.com/bug?extid=bf068cf224727e479bfa

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

==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:183 [inline]
BUG: KASAN: use-after-free in atomic_read arch/x86/include/asm/atomic.h:27 [inline]
BUG: KASAN: use-after-free in refcount_dec_not_one+0x9a/0xc0 lib/refcount.c:270
Read of size 4 at addr ffff888097d46b18 by task systemd-udevd/21974

CPU: 0 PID: 21974 Comm: systemd-udevd Not tainted 4.14.221-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
nbd: must specify at least one socket
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_load4_noabort+0x68/0x70 mm/kasan/report.c:429
__read_once_size include/linux/compiler.h:183 [inline]
atomic_read arch/x86/include/asm/atomic.h:27 [inline]
refcount_dec_not_one+0x9a/0xc0 lib/refcount.c:270
refcount_dec_and_mutex_lock+0x1a/0x60 lib/refcount.c:309
nbd_put drivers/block/nbd.c:228 [inline]
nbd_release+0xf3/0x150 drivers/block/nbd.c:1446
__blkdev_put+0x5aa/0x800 fs/block_dev.c:1803
nbd: must specify at least one socket
blkdev_close+0x86/0xb0 fs/block_dev.c:1875
__fput+0x25f/0x7a0 fs/file_table.c:210
task_work_run+0x11f/0x190 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:191 [inline]
exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
NILFS (loop5): unable to read superblock
entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x7f6b11c8b270
RSP: 002b:00007ffe2a6e3a28 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000007 RCX: 00007f6b11c8b270
RDX: 000000000aba9500 RSI: 0000000000000000 RDI: 0000000000000007
RBP: 00007f6b12b44710 R08: 0000000000000045 R09: 0000000000000018
R10: 000055f9781fb648 R11: 0000000000000246 R12: 0000000000000000
R13: 000055f9781fe550 R14: 0000000000000003 R15: 000000000000000e

Allocated by task 21984:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
kmalloc include/linux/slab.h:488 [inline]
kzalloc include/linux/slab.h:661 [inline]
nbd_dev_add+0x7c/0x800 drivers/block/nbd.c:1611
nbd_genl_connect+0x3a4/0x1400 drivers/block/nbd.c:1756
genl_family_rcv_msg+0x572/0xb20 net/netlink/genetlink.c:600
genl_rcv_msg+0xaf/0x140 net/netlink/genetlink.c:625
netlink_rcv_skb+0x125/0x390 net/netlink/af_netlink.c:2433
genl_rcv+0x24/0x40 net/netlink/genetlink.c:636
netlink_unicast_kernel net/netlink/af_netlink.c:1287 [inline]
netlink_unicast+0x437/0x610 net/netlink/af_netlink.c:1313
netlink_sendmsg+0x62e/0xb80 net/netlink/af_netlink.c:1878
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb5/0x100 net/socket.c:656
___sys_sendmsg+0x6c8/0x800 net/socket.c:2062
__sys_sendmsg+0xa3/0x120 net/socket.c:2096
SYSC_sendmsg net/socket.c:2107 [inline]
SyS_sendmsg+0x27/0x40 net/socket.c:2103
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 21974:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
nbd_dev_remove drivers/block/nbd.c:223 [inline]
nbd_put.part.0+0x100/0x140 drivers/block/nbd.c:231
nbd_put drivers/block/nbd.c:267 [inline]
nbd_config_put+0x62a/0x810 drivers/block/nbd.c:1172
nbd_release+0xdf/0x150 drivers/block/nbd.c:1445
__blkdev_put+0x5aa/0x800 fs/block_dev.c:1803
blkdev_close+0x86/0xb0 fs/block_dev.c:1875
__fput+0x25f/0x7a0 fs/file_table.c:210
task_work_run+0x11f/0x190 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:191 [inline]
exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff888097d46a40
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 216 bytes inside of
512-byte region [ffff888097d46a40, ffff888097d46c40)
The buggy address belongs to the page:
page:ffffea00025f5180 count:1 mapcount:0 mapping:ffff888097d46040 index:0xffff888097d46040
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff888097d46040 ffff888097d46040 0000000100000005
raw: ffffea0002d236e0 ffffea0002842c20 ffff88813fe80940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888097d46a00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff888097d46a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888097d46b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888097d46b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888097d46c00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================


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

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Feb 21, 2021, 1:21:19 AM2/21/21
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 255b58a2 Linux 4.19.176
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1665f79cd00000
kernel config: https://syzkaller.appspot.com/x/.config?x=b270830ae46c1d6f
dashboard link: https://syzkaller.appspot.com/bug?extid=8ec6dfaa3508f7893ce9

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+8ec6df...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
BUG: KASAN: use-after-free in refcount_dec_not_one+0x71/0x1d0 lib/refcount.c:269
Read of size 4 at addr ffff888097d4b118 by task systemd-udevd/2927

CPU: 0 PID: 2927 Comm: systemd-udevd Not tainted 4.19.176-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+0x1fc/0x2ef lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
kasan_report+0x8f/0xa0 mm/kasan/report.c:412
atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
refcount_dec_not_one+0x71/0x1d0 lib/refcount.c:269
refcount_dec_and_mutex_lock+0x1c/0x80 lib/refcount.c:308
nbd_put drivers/block/nbd.c:228 [inline]
nbd_release+0x108/0x170 drivers/block/nbd.c:1462
__blkdev_put+0x636/0x870 fs/block_dev.c:1819
blkdev_close+0x86/0xb0 fs/block_dev.c:1888
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f8b1c7d8270
Code: 73 01 c3 48 8b 0d 38 7d 20 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 59 c1 20 00 00 75 10 b8 03 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 ee fb ff ff 48 89 04 24
RSP: 002b:00007ffce81d6ec8 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000007 RCX: 00007f8b1c7d8270
RDX: 000000000aba9500 RSI: 0000000000000000 RDI: 0000000000000007
RBP: 00007f8b1d691710 R08: 000000000000004a R09: 0000000000000008
R10: 00005590706fba48 R11: 0000000000000246 R12: 0000000000000000
R13: 00005590706fc8c0 R14: 0000000000000003 R15: 000000000000000e

Allocated by task 2914:
kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
nbd_dev_add+0x44/0x890 drivers/block/nbd.c:1627
nbd_genl_connect+0x4cc/0x1630 drivers/block/nbd.c:1773
genl_family_rcv_msg+0x642/0xc40 net/netlink/genetlink.c:602
genl_rcv_msg+0xbf/0x160 net/netlink/genetlink.c:627
netlink_rcv_skb+0x160/0x440 net/netlink/af_netlink.c:2455
genl_rcv+0x24/0x40 net/netlink/genetlink.c:638
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x4d5/0x690 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x6bb/0xc40 net/netlink/af_netlink.c:1909
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:632
___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2115
__sys_sendmsg net/socket.c:2153 [inline]
__do_sys_sendmsg net/socket.c:2162 [inline]
__se_sys_sendmsg net/socket.c:2160 [inline]
__x64_sys_sendmsg+0x132/0x220 net/socket.c:2160
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 2927:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
nbd_dev_remove drivers/block/nbd.c:223 [inline]
nbd_put.part.0+0xfe/0x140 drivers/block/nbd.c:231
nbd_put drivers/block/nbd.c:275 [inline]
nbd_config_put+0x6a0/0x870 drivers/block/nbd.c:1185
nbd_release+0xf4/0x170 drivers/block/nbd.c:1461
__blkdev_put+0x636/0x870 fs/block_dev.c:1819
blkdev_close+0x86/0xb0 fs/block_dev.c:1888
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888097d4b040
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 216 bytes inside of
512-byte region [ffff888097d4b040, ffff888097d4b240)
The buggy address belongs to the page:
page:ffffea00025f52c0 count:1 mapcount:0 mapping:ffff88813bff0940 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea00028263c8 ffffea00027fd448 ffff88813bff0940
raw: 0000000000000000 ffff888097d4b040 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888097d4b000: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff888097d4b080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888097d4b100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888097d4b180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888097d4b200: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc

syzbot

unread,
Apr 17, 2021, 3:17:23 AM4/17/21
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: cf256fbc Linux 4.14.231
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=132d645ad00000
kernel config: https://syzkaller.appspot.com/x/.config?x=403e68efdb1dcca6
dashboard link: https://syzkaller.appspot.com/bug?extid=bf068cf224727e479bfa
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17257229d00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a92fd9d00000

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

==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:183 [inline]
BUG: KASAN: use-after-free in atomic_read arch/x86/include/asm/atomic.h:27 [inline]
BUG: KASAN: use-after-free in refcount_dec_not_one+0x9a/0xc0 lib/refcount.c:270
Read of size 4 at addr ffff88809a9c5d98 by task systemd-udevd/8218

CPU: 1 PID: 8218 Comm: systemd-udevd Not tainted 4.14.231-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_load4_noabort+0x68/0x70 mm/kasan/report.c:429
__read_once_size include/linux/compiler.h:183 [inline]
atomic_read arch/x86/include/asm/atomic.h:27 [inline]
refcount_dec_not_one+0x9a/0xc0 lib/refcount.c:270
refcount_dec_and_mutex_lock+0x1a/0x60 lib/refcount.c:309
nbd_put drivers/block/nbd.c:228 [inline]
nbd_release+0xf3/0x150 drivers/block/nbd.c:1446
__blkdev_put+0x5aa/0x800 fs/block_dev.c:1803
blkdev_close+0x86/0xb0 fs/block_dev.c:1875
__fput+0x25f/0x7a0 fs/file_table.c:210
task_work_run+0x11f/0x190 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:191 [inline]
exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x7f3bc5ed7270
RSP: 002b:00007ffd1c6f2b48 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000007 RCX: 00007f3bc5ed7270
RDX: 000000000aba9500 RSI: 0000000000000000 RDI: 0000000000000007
RBP: 00007f3bc6d91710 R08: 000000000000004a R09: 0000000000000008
R10: 000055c4d58e6348 R11: 0000000000000246 R12: 0000000000000000
R13: 000055c4d58de880 R14: 0000000000000003 R15: 000000000000000e

Allocated by task 8198:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
kmalloc include/linux/slab.h:488 [inline]
kzalloc include/linux/slab.h:661 [inline]
nbd_dev_add+0x7c/0x800 drivers/block/nbd.c:1611
nbd_genl_connect+0x3a4/0x1400 drivers/block/nbd.c:1756
genl_family_rcv_msg+0x572/0xb20 net/netlink/genetlink.c:600
genl_rcv_msg+0xaf/0x140 net/netlink/genetlink.c:625
netlink_rcv_skb+0x125/0x390 net/netlink/af_netlink.c:2433
genl_rcv+0x24/0x40 net/netlink/genetlink.c:636
netlink_unicast_kernel net/netlink/af_netlink.c:1287 [inline]
netlink_unicast+0x437/0x610 net/netlink/af_netlink.c:1313
netlink_sendmsg+0x62e/0xb80 net/netlink/af_netlink.c:1878
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb5/0x100 net/socket.c:656
___sys_sendmsg+0x6c8/0x800 net/socket.c:2062
__sys_sendmsg+0xa3/0x120 net/socket.c:2096
SYSC_sendmsg net/socket.c:2107 [inline]
SyS_sendmsg+0x27/0x40 net/socket.c:2103
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 8218:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
nbd_dev_remove drivers/block/nbd.c:223 [inline]
nbd_put.part.0+0x100/0x140 drivers/block/nbd.c:231
nbd_put drivers/block/nbd.c:267 [inline]
nbd_config_put+0x62a/0x810 drivers/block/nbd.c:1172
nbd_release+0xdf/0x150 drivers/block/nbd.c:1445
__blkdev_put+0x5aa/0x800 fs/block_dev.c:1803
blkdev_close+0x86/0xb0 fs/block_dev.c:1875
__fput+0x25f/0x7a0 fs/file_table.c:210
task_work_run+0x11f/0x190 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:191 [inline]
exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff88809a9c5cc0
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 216 bytes inside of
512-byte region [ffff88809a9c5cc0, ffff88809a9c5ec0)
The buggy address belongs to the page:
page:ffffea00026a7140 count:1 mapcount:0 mapping:ffff88809a9c5040 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff88809a9c5040 0000000000000000 0000000100000006
raw: ffffea0002af6920 ffffea0002bd7fe0 ffff88813fe80940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809a9c5c80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff88809a9c5d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809a9c5d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88809a9c5e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809a9c5e80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

syzbot

unread,
May 25, 2021, 1:00:24 AM5/25/21
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 1e986fe9 Linux 4.19.191
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=11074f27d00000
kernel config: https://syzkaller.appspot.com/x/.config?x=44f656322d91580c
dashboard link: https://syzkaller.appspot.com/bug?extid=8ec6dfaa3508f7893ce9
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1335034bd00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=105d4e4bd00000

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

==================================================================
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
BUG: KASAN: use-after-free in refcount_dec_not_one+0x71/0x1d0 lib/refcount.c:269
Read of size 4 at addr ffff8880ab7ff8d8 by task systemd-udevd/8181

CPU: 1 PID: 8181 Comm: systemd-udevd Not tainted 4.19.191-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+0x1fc/0x2ef lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
kasan_report+0x8f/0xa0 mm/kasan/report.c:412
atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
refcount_dec_not_one+0x71/0x1d0 lib/refcount.c:269
refcount_dec_and_mutex_lock+0x1c/0x80 lib/refcount.c:308
nbd_put drivers/block/nbd.c:228 [inline]
nbd_release+0x108/0x170 drivers/block/nbd.c:1462
__blkdev_put+0x636/0x870 fs/block_dev.c:1819
blkdev_close+0x86/0xb0 fs/block_dev.c:1888
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7fa8d5e0e270
Code: 73 01 c3 48 8b 0d 38 7d 20 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 59 c1 20 00 00 75 10 b8 03 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 ee fb ff ff 48 89 04 24
RSP: 002b:00007fffae034c48 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000007 RCX: 00007fa8d5e0e270
RDX: 000000000aba9500 RSI: 0000000000000000 RDI: 0000000000000007
RBP: 00007fa8d6cc8710 R08: 000055c3551a4eb0 R09: 0000000000000008
R10: 000055c3551a4c98 R11: 0000000000000246 R12: 0000000000000000
R13: 000055c3551a3880 R14: 0000000000000003 R15: 000000000000000e

Allocated by task 8178:
kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
nbd_dev_add+0x44/0x890 drivers/block/nbd.c:1627
nbd_genl_connect+0x4cc/0x1630 drivers/block/nbd.c:1773
genl_family_rcv_msg+0x642/0xc40 net/netlink/genetlink.c:602
genl_rcv_msg+0xbf/0x160 net/netlink/genetlink.c:627
netlink_rcv_skb+0x160/0x440 net/netlink/af_netlink.c:2455
genl_rcv+0x24/0x40 net/netlink/genetlink.c:638
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x4d5/0x690 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x6bb/0xc40 net/netlink/af_netlink.c:1909
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:632
___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2115
__sys_sendmsg net/socket.c:2153 [inline]
__do_sys_sendmsg net/socket.c:2162 [inline]
__se_sys_sendmsg net/socket.c:2160 [inline]
__x64_sys_sendmsg+0x132/0x220 net/socket.c:2160
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8181:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
nbd_dev_remove drivers/block/nbd.c:223 [inline]
nbd_put.part.0+0xfe/0x140 drivers/block/nbd.c:231
nbd_put drivers/block/nbd.c:275 [inline]
nbd_config_put+0x6a0/0x870 drivers/block/nbd.c:1185
nbd_release+0xf4/0x170 drivers/block/nbd.c:1461
__blkdev_put+0x636/0x870 fs/block_dev.c:1819
blkdev_close+0x86/0xb0 fs/block_dev.c:1888
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880ab7ff800
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 216 bytes inside of
512-byte region [ffff8880ab7ff800, ffff8880ab7ffa00)
The buggy address belongs to the page:
page:ffffea0002adffc0 count:1 mapcount:0 mapping:ffff88813bff0940 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002cf0a08 ffffea0002adb6c8 ffff88813bff0940
raw: 0000000000000000 ffff8880ab7ff080 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880ab7ff780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880ab7ff800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880ab7ff880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880ab7ff900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880ab7ff980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Reply all
Reply to author
Forward
0 new messages