refcount_t: addition on 0; use-after-free. ------------[ cut here ]------------ kernel BUG at lib/refcount.c:34! Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 2 UID: 0 PID: 9754 Comm: syz.3.951 Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:refcount_warn_saturate.cold+0x12/0x14 lib/refcount.c:34 Code: 89 ea be 01 00 00 00 48 c7 c7 40 cd c3 90 e8 0a 5a 01 00 e9 e2 e6 03 04 e8 d0 8a d7 00 48 c7 c7 20 51 81 8c e8 04 85 eb ff 90 <0f> 0b e8 bc 8a d7 00 48 c7 c7 c0 51 81 8c e8 f0 84 eb ff 90 0f 0b RSP: 0018:ffffc9000396fbf8 EFLAGS: 00010282 RAX: 000000000000002a RBX: ffff888028c34128 RCX: 0000000000000000 RDX: 000000000000002a RSI: ffffffff81ec2819 RDI: fffff5200072df70 RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000 R10: ffffc9000396f9bf R11: 0000000000000001 R12: ffff888028c34128 R13: 0000000000000001 R14: ffff88806a548000 R15: ffff888028c340f0 FS: 00007f588a9206c0(0000) GS:ffff8880d4675000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f16dc1f11e8 CR3: 000000005e466000 CR4: 0000000000352ef0 Call Trace: __refcount_add include/linux/refcount.h:289 [inline] __refcount_inc include/linux/refcount.h:366 [inline] refcount_inc include/linux/refcount.h:383 [inline] kref_get include/linux/kref.h:45 [inline] kobject_get+0x12f/0x150 lib/kobject.c:643 sysfs_break_active_protection+0x1d/0xd0 fs/sysfs/file.c:471 md_attr_store+0x2c9/0x330 drivers/md/md.c:6167 sysfs_kf_write+0xf2/0x150 fs/sysfs/file.c:145 kernfs_fop_write_iter+0x3e0/0x5f0 fs/kernfs/file.c:345 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6af/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f588999fb19 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f588a920028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f5889c26090 RCX: 00007f588999fb19 RDX: 0000000000000005 RSI: 0000200000000540 RDI: 0000000000000001 RBP: 00007f5889a37b70 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f5889c26128 R14: 00007f5889c26090 R15: 00007ffe32561ce8 Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:refcount_warn_saturate.cold+0x12/0x14 lib/refcount.c:34 Code: 89 ea be 01 00 00 00 48 c7 c7 40 cd c3 90 e8 0a 5a 01 00 e9 e2 e6 03 04 e8 d0 8a d7 00 48 c7 c7 20 51 81 8c e8 04 85 eb ff 90 <0f> 0b e8 bc 8a d7 00 48 c7 c7 c0 51 81 8c e8 f0 84 eb ff 90 0f 0b RSP: 0018:ffffc9000396fbf8 EFLAGS: 00010282 RAX: 000000000000002a RBX: ffff888028c34128 RCX: 0000000000000000 RDX: 000000000000002a RSI: ffffffff81ec2819 RDI: fffff5200072df70 RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000 R10: ffffc9000396f9bf R11: 0000000000000001 R12: ffff888028c34128 R13: 0000000000000001 R14: ffff88806a548000 R15: ffff888028c340f0 FS: 00007f588a9206c0(0000) GS:ffff8880d4775000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055ebbe1b3fc0 CR3: 000000005e466000 CR4: 0000000000352ef0 DR0: 0000000000000000 DR1: 000000000000800e DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400