Skip to contentSkip to conversation

BUG: unable to handle kernel paging request in remove_spares

syzbot syzbot 2 participants 3 messages Nov 5 – Nov 19

Subsystems (3)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following issue on:

HEAD commit:    6628e7d4c6b2 Linux 7.4-rc1
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=15e6892d580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=a58b6b4d667e7a61
dashboard link: https://syzkaller.appspot.com/bug?extid=a53c2918175b36cfd601
compiler:       Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=167b4359580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f7244eb9fc82/disk-6628e7d4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/7915cff348a4/vmlinux-6628e7d4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e1ce9287de30/Image-6628e7d4.gz.xz

AI-generated root cause summary:
In the MD (Multiple Devices / RAID) subsystem, md_start_sync is scheduled as a work item on the md_misc workqueue to initiate resynchronization or manage spare devices. For read-only arrays (!md_is_rdwr(mddev)), md_start_sync executes remove_and_add_spares(), which invokes remove_spares(). However, md_start_sync fails to verify whether the array's personality (mddev->pers) is still valid before calling into personality operations, and array stop/detach sequences do not ensure that mddev->sync_work is completely halted or prevented from running after mddev->pers is cleared. When remove_spares() executes with mddev->pers == NULL, it attempts to invoke mddev->pers->hot_remove_disk (located at offset 0x50), triggering a NULL pointer dereference crash.

full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=a53c2918175b36cfd601

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]
Unable to handle kernel paging request at virtual address dfff80000000000a
KASAN: null-ptr-deref in range [0x0000000000000050-0x0000000000000057]

Mem abort info:
ESR = 0x0000000096000005
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x05: level 1 translation fault
Data abort info:
ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
CM = 0, WnR = 0, TnD = 0, TagAccess = 0
GCS = 0, Overlay = 0, DirtyBit = 0
[dfff80000000000a] address between user and kernel address ranges

Internal error: Oops: 0000000096000005 [#1]  SMP
Modules linked in:
CPU: 1 UID: 0 PID: 4993 Comm: kworker/1:5 Not tainted syzkaller #0 PREEMPT 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/23/2026
Workqueue: md_misc md_start_sync
pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : remove_spares+0x100/0x3c8 drivers/md/md.c:10182
lr : remove_spares+0xe0/0x3c8 drivers/md/md.c:10181

sp : ffff800097277900
x29: ffff8000972779a0 x28: ffff0000f4c1c070 x27: 1fffe0001e98380c
x26: dfff800000000000 x25: ffff700012e4ef24 x24: 0000000000000050
x23: 0000000000000000 x22: ffff0000f4c1d108 x21: 0000000000000000
x20: ffff0000f4c1c058 x19: ffff0000f4c1c060 x18: 00000000ffffffff
x17: ffff80012364b000 x16: ffff80008f920000 x15: ffff80008b586000
x14: 00000000001b18f8 x13: 0000000000000001 x12: 0000000000000000
x11: 0000000000000000 x10: ffff60001e983a48 x9 : 0000000000000000 x8 : 000000000000000a x7 : 0000000000000000 x6 : 0000000000000000 x5 : 0000000000000001 x4 : 0000000000000008 x3 : ffff8000841063ac x2 : 0000000000000000 x1 : ffff0000c4d55880 x0 : 0000000000000001

Call trace:
 remove_spares+0x100/0x3c8 drivers/md/md.c:10182 (P)
 remove_and_add_spares+0xf4/0x580 drivers/md/md.c:10207
 md_start_sync+0x1f8/0xc80 drivers/md/md.c:10323
 process_one_work kernel/workqueue.c:3495 [inline]
 process_scheduled_works+0x91c/0x1250 kernel/workqueue.c:3578
 worker_thread+0x798/0xbd0 kernel/workqueue.c:3659
 kthread+0x304/0x3d4 kernel/kthread.c:436
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:854
Code: 972be018 f9400268 91014118 d343ff08 (387a6908) 
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
   0:	972be018 	bl	0xfffffffffcaf8060
   4:	f9400268 	ldr	x8, [x19]
   8:	91014118 	add	x24, x8, #0x50
   c:	d343ff08 	lsr	x8, x24, #3
* 10:	387a6908 	ldrb	w8, [x8, x26] <-- trapping instruction

---
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 [email protected].

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

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

author syzbot
#1 lore raw
syzbot has found a reproducer for the following issue on:

syzbot has found a reproducer for the following issue on:

HEAD commit:    20eef29b7c84 Merge tag 'arc-fixes-7.4' of git://git.kernel..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1186ff3d580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=1cf189394a856f11
dashboard link: https://syzkaller.appspot.com/bug?extid=a53c2918175b36cfd601
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=17f8f94d580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=173f9411580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-20eef29b.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/bb852a1ddb76/vmlinux-20eef29b.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4c636c3f4242/bzImage-20eef29b.xz

AI-generated root cause summary:
In the MD (Multiple Devices / RAID) subsystem, md_start_sync is scheduled as a work item on the md_misc workqueue to initiate resynchronization or manage spare devices. For read-only arrays (!md_is_rdwr(mddev)), md_start_sync executes remove_and_add_spares(), which invokes remove_spares(). However, md_start_sync fails to verify whether the array's personality (mddev->pers) is still valid before calling into personality operations, and array stop/detach sequences do not ensure that mddev->sync_work is completely halted or prevented from running after mddev->pers is cleared. When remove_spares() executes with mddev->pers == NULL, it attempts to invoke mddev->pers->hot_remove_disk (located at offset 0x50), triggering a NULL pointer dereference crash.

full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=a53c2918175b36cfd601

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]
Oops: general protection fault, probably for non-canonical address 0xdffffc000000000a: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000050-0x0000000000000057]
CPU: 2 UID: 0 PID: 66 Comm: kworker/2:2 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: md_misc md_start_sync
RIP: 0010:remove_spares+0x147/0x540 drivers/md/md.c:10182
Code: 67 60 f9 45 84 ff 74 55 e8 e6 6c 60 f9 48 8b 44 24 10 80 38 00 0f 85 83 03 00 00 49 8b 45 08 48 8d 78 50 48 89 fa 48 c1 ea 03 <42> 80 3c 22 00 0f 85 78 03 00 00 48 89 de 4c 89 ef 48 8b 40 50 2e
RSP: 0018:ffffc90000d47a10 EFLAGS: 00010206
RAX: 0000000000000000 RBX: ffff888059649108 RCX: 0000000000000000
RDX: 000000000000000a RSI: ffffffff88ae1bfa RDI: 0000000000000050
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001
R10: ffff8880596491cf R11: 0000000000000000 R12: dffffc0000000000
R13: ffff888059648058 R14: ffff888059648070 R15: 0000000000000001
FS:  0000000000000000(0000) GS:ffff8880d4669000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b30924008 CR3: 0000000051ca3000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 remove_and_add_spares+0x6c7/0x7f0 drivers/md/md.c:10207
 md_start_sync+0x736/0xea0 drivers/md/md.c:10323
 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3495
 process_scheduled_works kernel/workqueue.c:3578 [inline]
 worker_thread+0x5ef/0xe50 kernel/workqueue.c:3659
 kthread+0x373/0x450 kernel/kthread.c:436
 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:remove_spares+0x147/0x540 drivers/md/md.c:10182
Code: 67 60 f9 45 84 ff 74 55 e8 e6 6c 60 f9 48 8b 44 24 10 80 38 00 0f 85 83 03 00 00 49 8b 45 08 48 8d 78 50 48 89 fa 48 c1 ea 03 <42> 80 3c 22 00 0f 85 78 03 00 00 48 89 de 4c 89 ef 48 8b 40 50 2e
RSP: 0018:ffffc90000d47a10 EFLAGS: 00010206
RAX: 0000000000000000 RBX: ffff888059649108 RCX: 0000000000000000
RDX: 000000000000000a RSI: ffffffff88ae1bfa RDI: 0000000000000050
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001
R10: ffff8880596491cf R11: 0000000000000000 R12: dffffc0000000000
R13: ffff888059648058 R14: ffff888059648070 R15: 0000000000000001
FS:  0000000000000000(0000) GS:ffff8880d4669000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b30924008 CR3: 0000000051ca3000 CR4: 0000000000352ef0
----------------
Code disassembly (best guess):
   0:	67 60                	addr32 (bad)
   2:	f9                   	stc
   3:	45 84 ff             	test   %r15b,%r15b
   6:	74 55                	je     0x5d
   8:	e8 e6 6c 60 f9       	call   0xf9606cf3
   d:	48 8b 44 24 10       	mov    0x10(%rsp),%rax
  12:	80 38 00             	cmpb   $0x0,(%rax)
  15:	0f 85 83 03 00 00    	jne    0x39e
  1b:	49 8b 45 08          	mov    0x8(%r13),%rax
  1f:	48 8d 78 50          	lea    0x50(%rax),%rdi
  23:	48 89 fa             	mov    %rdi,%rdx
  26:	48 c1 ea 03          	shr    $0x3,%rdx
* 2a:	42 80 3c 22 00       	cmpb   $0x0,(%rdx,%r12,1) <-- trapping instruction
  2f:	0f 85 78 03 00 00    	jne    0x3ad
  35:	48 89 de             	mov    %rbx,%rsi
  38:	4c 89 ef             	mov    %r13,%rdi
  3b:	48 8b 40 50          	mov    0x50(%rax),%rax
  3f:	2e                   	cs
#2 lore raw
Quoted 93 lines · syzbot

syzbot has found a reproducer for the following issue on:

HEAD commit:    20eef29b7c84 Merge tag 'arc-fixes-7.4' of git://git.kernel..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1186ff3d580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=1cf189394a856f11
dashboard link: https://syzkaller.appspot.com/bug?extid=a53c2918175b36cfd601
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=17f8f94d580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=173f9411580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-20eef29b.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/bb852a1ddb76/vmlinux-20eef29b.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4c636c3f4242/bzImage-20eef29b.xz

AI-generated root cause summary:
In the MD (Multiple Devices / RAID) subsystem, md_start_sync is scheduled as a work item on the md_misc workqueue to initiate resynchronization or manage spare devices. For read-only arrays (!md_is_rdwr(mddev)), md_start_sync executes remove_and_add_spares(), which invokes remove_spares(). However, md_start_sync fails to verify whether the array's personality (mddev->pers) is still valid before calling into personality operations, and array stop/detach sequences do not ensure that mddev->sync_work is completely halted or prevented from running after mddev->pers is cleared. When remove_spares() executes with mddev->pers == NULL, it attempts to invoke mddev->pers->hot_remove_disk (located at offset 0x50), triggering a NULL pointer dereference crash.

full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=a53c2918175b36cfd601

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]
Oops: general protection fault, probably for non-canonical address 0xdffffc000000000a: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000050-0x0000000000000057]
CPU: 2 UID: 0 PID: 66 Comm: kworker/2:2 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: md_misc md_start_sync
RIP: 0010:remove_spares+0x147/0x540 drivers/md/md.c:10182
Code: 67 60 f9 45 84 ff 74 55 e8 e6 6c 60 f9 48 8b 44 24 10 80 38 00 0f 85 83 03 00 00 49 8b 45 08 48 8d 78 50 48 89 fa 48 c1 ea 03 <42> 80 3c 22 00 0f 85 78 03 00 00 48 89 de 4c 89 ef 48 8b 40 50 2e
RSP: 0018:ffffc90000d47a10 EFLAGS: 00010206
RAX: 0000000000000000 RBX: ffff888059649108 RCX: 0000000000000000
RDX: 000000000000000a RSI: ffffffff88ae1bfa RDI: 0000000000000050
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001
R10: ffff8880596491cf R11: 0000000000000000 R12: dffffc0000000000
R13: ffff888059648058 R14: ffff888059648070 R15: 0000000000000001
FS:  0000000000000000(0000) GS:ffff8880d4669000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b30924008 CR3: 0000000051ca3000 CR4: 0000000000352ef0
Call Trace:
<TASK>
remove_and_add_spares+0x6c7/0x7f0 drivers/md/md.c:10207
md_start_sync+0x736/0xea0 drivers/md/md.c:10323
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3495
process_scheduled_works kernel/workqueue.c:3578 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3659
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:remove_spares+0x147/0x540 drivers/md/md.c:10182
Code: 67 60 f9 45 84 ff 74 55 e8 e6 6c 60 f9 48 8b 44 24 10 80 38 00 0f 85 83 03 00 00 49 8b 45 08 48 8d 78 50 48 89 fa 48 c1 ea 03 <42> 80 3c 22 00 0f 85 78 03 00 00 48 89 de 4c 89 ef 48 8b 40 50 2e
RSP: 0018:ffffc90000d47a10 EFLAGS: 00010206
RAX: 0000000000000000 RBX: ffff888059649108 RCX: 0000000000000000
RDX: 000000000000000a RSI: ffffffff88ae1bfa RDI: 0000000000000050
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001
R10: ffff8880596491cf R11: 0000000000000000 R12: dffffc0000000000
R13: ffff888059648058 R14: ffff888059648070 R15: 0000000000000001
FS:  0000000000000000(0000) GS:ffff8880d4669000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b30924008 CR3: 0000000051ca3000 CR4: 0000000000352ef0
----------------
Code disassembly (best guess):
  0:	67 60                	addr32 (bad)
  2:	f9                   	stc
  3:	45 84 ff             	test   %r15b,%r15b
  6:	74 55                	je     0x5d
  8:	e8 e6 6c 60 f9       	call   0xf9606cf3
  d:	48 8b 44 24 10       	mov    0x10(%rsp),%rax
 12:	80 38 00             	cmpb   $0x0,(%rax)
 15:	0f 85 83 03 00 00    	jne    0x39e
 1b:	49 8b 45 08          	mov    0x8(%r13),%rax
 1f:	48 8d 78 50          	lea    0x50(%rax),%rdi
 23:	48 89 fa             	mov    %rdi,%rdx
 26:	48 c1 ea 03          	shr    $0x3,%rdx
* 2a:	42 80 3c 22 00       	cmpb   $0x0,(%rdx,%r12,1) <-- trapping instruction
 2f:	0f 85 78 03 00 00    	jne    0x3ad
 35:	48 89 de             	mov    %rbx,%rsi
 38:	4c 89 ef             	mov    %r13,%rdi
 3b:	48 8b 40 50          	mov    0x50(%rax),%rax
Quoted 1 line

3f: 2e cs

v5 fix is here:
https://lore.kernel.org/linux-raid/[email protected]/

Thanks,
Li Youhong