* [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt
@ 2026-08-21 7:52 syzbot
2026-08-21 12:14 ` Forwarded: Re: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: syzbot @ 2026-08-21 7:52 UTC (permalink / raw)
To: gregkh, linux-kernel, linux-usb, mathias.nyman, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 21d6ac051080 Merge branch 'for-next/core' into for-kernelci
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=1366d949580000
kernel config: https://syzkaller.appspot.com/x/.config?x=d1128bc53f2ef7f3
dashboard link: https://syzkaller.appspot.com/bug?extid=c90273bf9017ef1462af
compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1741d6c6580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11d03a79580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/88380e2ddcb9/disk-21d6ac05.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5dba5c2896b7/vmlinux-21d6ac05.xz
kernel image: https://storage.googleapis.com/syzbot-assets/52ac739e37e0/Image-21d6ac05.gz.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c90273bf9017ef1462af@syzkaller.appspotmail.com
EXT4-fs (nvme0n1p2): shut down requested (2)
Aborting journal on device nvme0n1p2-8.
xhci_hcd 0000:00:02.0: xHCI Host Controller
xhci_hcd 0000:00:02.0: new USB bus registered, assigned bus number 34
Unable to handle kernel paging request at virtual address ffff8000936e40ff
KASAN: probably user-memory-access in range [0x000000049b7207f8-0x000000049b7207ff]
Mem abort info:
ESR = 0x0000000096000021
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x21: alignment fault
Data abort info:
ISV = 0, ISS = 0x00000021, ISS2 = 0x00000000
CM = 0, WnR = 0, TnD = 0, TagAccess = 0
GCS = 0, Overlay = 0, DirtyBit = 0
swapper pgtable: 4k pages, 48-bit VAs, pgdp=000000021b049000
[ffff8000936e40ff] pgd=0000000000000000, p4d=1000000221341003, pud=1000000221342003, pmd=1000000106b4b403, pte=0068010000000713
Internal error: Oops: 0000000096000021 [#1] SMP
Modules linked in:
CPU: 1 UID: 0 PID: 4935 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/07/2026
pstate: 63400005 (nZCv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : __raw_readl arch/arm64/include/asm/io.h:84 [inline]
pc : readl include/asm-generic/io.h:231 [inline]
pc : xhci_quiesce drivers/usb/host/xhci.c:107 [inline]
pc : xhci_halt+0x64/0x1ec drivers/usb/host/xhci.c:125
lr : xhci_halt+0x40/0x1ec drivers/usb/host/xhci.c:124
sp : ffff8000963773c0
x29: ffff8000963773c0 x28: ffff0000d23fa000 x27: dfff800000000000
x26: ffff0000d23fa418 x25: 0000000000000f01 x24: ffff0000d23fa6e8
x23: ffff0000c2f4a0d0 x22: ffff0000d23fa418 x21: dfff800000000000
x20: 1fffe0001a47f483 x19: ffff0000d23fa400 x18: 00000000ffffffff
x17: ffff80008a7d6000 x16: 0000000000000005 x15: ffff80008a35fda0
x14: ffff80008a5d5e28 x13: 0000000000000004 x12: 0000000000000000
x11: ffff8000963772e0 x10: 00000000fffffbf2 x9 : 2afdbc7a43e86800
x8 : ffff8000936e40ff x7 : 0000000000000000 x6 : 0000000000000000
x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff8000833104ec
x2 : 0000000000000002 x1 : ffff0000c4ec57c0 x0 : 0000000000000000
Call trace:
__raw_readl arch/arm64/include/asm/io.h:84 [inline] (P)
readl include/asm-generic/io.h:231 [inline] (P)
xhci_quiesce drivers/usb/host/xhci.c:107 [inline] (P)
xhci_halt+0x64/0x1ec drivers/usb/host/xhci.c:125 (P)
xhci_gen_setup+0x5d8/0x111c drivers/usb/host/xhci.c:5496
xhci_pci_setup+0x110/0x44c drivers/usb/host/xhci-pci.c:579
usb_add_hcd+0x5c4/0xdec drivers/usb/core/hcd.c:2935
usb_hcd_pci_probe+0x63c/0xaa4 drivers/usb/core/hcd-pci.c:267
xhci_pci_common_probe+0x90/0x760 drivers/usb/host/xhci-pci.c:633
xhci_pci_probe+0x44/0xdc drivers/usb/host/xhci-pci.c:717
local_pci_probe+0xc8/0x158 drivers/pci/pci-driver.c:332
pci_call_probe drivers/pci/pci-driver.c:394 [inline]
__pci_device_probe drivers/pci/pci-driver.c:455 [inline]
pci_device_probe+0x460/0x8d4 drivers/pci/pci-driver.c:489
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x29c/0x800 drivers/base/dd.c:706
__driver_probe_device+0x1e0/0x350 drivers/base/dd.c:868
device_driver_attach+0x58/0xac drivers/base/dd.c:1203
bind_store+0xf4/0x14c drivers/base/bus.c:267
drv_attr_store+0x80/0xa4 drivers/base/bus.c:125
sysfs_kf_write+0xe0/0x108 fs/sysfs/file.c:145
kernfs_fop_write_iter+0x260/0x3b8 fs/kernfs/file.c:345
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x51c/0xa0c fs/read_write.c:687
ksys_write+0x12c/0x228 fs/read_write.c:739
__do_sys_write fs/read_write.c:750 [inline]
__se_sys_write fs/read_write.c:747 [inline]
__arm64_sys_write+0x84/0x98 fs/read_write.c:747
__invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
el0_svc+0x64/0x260 arch/arm64/kernel/entry-common.c:758
el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:777
el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:590
Code: 9762248f f94002c8 128081aa d503201f (b9400108)
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
0: 9762248f bl 0xfffffffffd88923c
4: f94002c8 ldr x8, [x22]
8: 128081aa mov w10, #0xfffffbf2 // #-1038
c: d503201f nop
* 10: b9400108 ldr w8, [x8] <-- 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 syzkaller@googlegroups.com.
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Forwarded: Re: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup()
2026-08-21 7:52 [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt syzbot
@ 2026-08-21 12:14 ` syzbot
2026-08-21 12:52 ` Forwarded: Re: [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt syzbot
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-08-21 12:14 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: Re: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup()
Author: erdaitianjiao@gmail.com
#syz test
^ permalink raw reply [flat|nested] 6+ messages in thread
* Forwarded: Re: [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt
2026-08-21 7:52 [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt syzbot
2026-08-21 12:14 ` Forwarded: Re: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
@ 2026-08-21 12:52 ` syzbot
2026-08-21 13:15 ` Forwarded: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-08-21 12:52 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: Re: [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt
Author: erdaitianjiao@gmail.com
#syz test
From f7f2199964ee2b4204aabd4d1190845f5ad1da62 Mon Sep 17 00:00:00 2001
From: erdaitianjiao <erdaitianjiao@gmail.com>
Date: Fri, 21 Aug 2026 19:07:10 +0800
Subject: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup()
xhci_hcd can be bound to arbitrary PCI devices via the
driver_override sysfs knob. When this happens to a device whose
MMIO registers are not xHCI capability registers,
xhci_gen_setup() reads CAPLENGTH from the foreign register
layout and uses it as a byte offset to compute op_regs.
A non-xHCI device can return a CAPLENGTH value that is
- not large enough to fit the capability register block, or
- not 4-byte aligned (e.g. the NVMe CAP register's low byte is
0xff, which becomes CAPLENGTH = 0xff).
The unaligned case is especially harmful on arm64: MMIO is
Device memory and Device-nGnRE accesses require natural
alignment, so readl(&op_regs->command) faults with an
alignment exception even when the address is within the
ioremapped region.
Validate CAPLENGTH in xhci_gen_setup() and fail probe with
-ENODEV if the value is smaller than 0x20 (capability registers
are 32 bytes per the xHCI spec), not 4-byte aligned, or leaves
no room for the operational register space within the mapped
region.
The run_regs_off read on the next line has the same shape, but
is not reachable on the xhci_halt code path and is left
untouched here.
Reproduced on a QEMU virt machine with a syzkaller repro that
unbinds the NVMe driver on 0000:00:02.0 and binds xhci_hcd via
driver_override. Before this patch the kernel Oopses and
panics; after, the probe is rejected cleanly (verified with 46
consecutive probe attempts, zero Oopses).
Reported-by: syzbot+c90273bf9017ef1462af@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=44c85514940262c7e2fad6f8fd0c07d8f2884154
Fixes: 552e0c4f12fe ("usb/xhci: move xhci_gen_setup() away from -pci.")
Signed-off-by: erdaitianjiao <erdaitianjiao@gmail.com>
---
drivers/usb/host/xhci.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 091c82ca8ee2..fb0075d0530f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -5432,7 +5432,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
*/
struct device *dev = hcd->self.sysdev;
int retval;
- u32 hcs_params1;
+ u32 hcs_params1, capbase;
/* Accept arbitrarily long scatter-gather lists */
hcd->self.sg_tablesize = ~0;
@@ -5453,8 +5453,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
mutex_init(&xhci->mutex);
xhci->main_hcd = hcd;
xhci->cap_regs = hcd->regs;
- xhci->op_regs = hcd->regs +
- HC_LENGTH(readl(&xhci->cap_regs->hc_capbase));
+ capbase = readl(&xhci->cap_regs->hc_capbase);
+ if (HC_LENGTH(capbase) < 0x20 ||
+ (HC_LENGTH(capbase) & 0x3) ||
+ (hcd->rsrc_len &&
+ HC_LENGTH(capbase) + sizeof(struct xhci_op_regs) > hcd->rsrc_len)) {
+ xhci_err(xhci, "Invalid CAPLENGTH %#x (rsrc_len %#lx)
",
+ HC_LENGTH(capbase), (unsigned long)hcd->rsrc_len);
+ return -ENODEV;
+ }
+ xhci->op_regs = hcd->regs + HC_LENGTH(capbase);
xhci->run_regs = hcd->regs +
(readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK);
/* Cache read-only capability registers */
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Forwarded: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup()
2026-08-21 7:52 [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt syzbot
2026-08-21 12:14 ` Forwarded: Re: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
2026-08-21 12:52 ` Forwarded: Re: [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt syzbot
@ 2026-08-21 13:15 ` syzbot
2026-08-21 13:40 ` Forwarded: Re: #syz test (re-run after sandbox SYZFAIL) syzbot
2026-08-21 14:14 ` Forwarded: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-08-21 13:15 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup()
Author: erdaitianjiao@gmail.com
#syz test
xhci_hcd can be bound to arbitrary PCI devices via the
driver_override sysfs knob. When this happens to a device whose
MMIO registers are not xHCI capability registers,
xhci_gen_setup() reads CAPLENGTH from the foreign register
layout and uses it as a byte offset to compute op_regs.
A non-xHCI device can return a CAPLENGTH value that is
- not large enough to fit the capability register block, or
- not 4-byte aligned (e.g. the NVMe CAP register's low byte is
0xff, which becomes CAPLENGTH = 0xff).
The unaligned case is especially harmful on arm64: MMIO is
Device memory and Device-nGnRE accesses require natural
alignment, so readl(&op_regs->command) faults with an
alignment exception even when the address is within the
ioremapped region.
Validate CAPLENGTH in xhci_gen_setup() and fail probe with
-ENODEV if the value is smaller than 0x20 (capability registers
are 32 bytes per the xHCI spec), not 4-byte aligned, or leaves
no room for the operational register space within the mapped
region.
The run_regs_off read on the next line has the same shape, but
is not reachable on the xhci_halt code path and is left
untouched here.
Reproduced on a QEMU virt machine with a syzkaller repro that
unbinds the NVMe driver on 0000:00:02.0 and binds xhci_hcd via
driver_override. Before this patch the kernel Oopses and
panics; after, the probe is rejected cleanly (verified with 46
consecutive probe attempts, zero Oopses).
Reported-by: syzbot+c90273bf9017ef1462af@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=44c85514940262c7e2fad6f8fd0c07d8f2884154
Fixes: 552e0c4f12fe ("usb/xhci: move xhci_gen_setup() away from -pci.")
Signed-off-by: erdaitianjiao <erdaitianjiao@gmail.com>
---
drivers/usb/host/xhci.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 091c82ca8ee2..fb0075d0530f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -5432,7 +5432,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
*/
struct device *dev = hcd->self.sysdev;
int retval;
- u32 hcs_params1;
+ u32 hcs_params1, capbase;
/* Accept arbitrarily long scatter-gather lists */
hcd->self.sg_tablesize = ~0;
@@ -5453,8 +5453,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
mutex_init(&xhci->mutex);
xhci->main_hcd = hcd;
xhci->cap_regs = hcd->regs;
- xhci->op_regs = hcd->regs +
- HC_LENGTH(readl(&xhci->cap_regs->hc_capbase));
+ capbase = readl(&xhci->cap_regs->hc_capbase);
+ if (HC_LENGTH(capbase) < 0x20 ||
+ (HC_LENGTH(capbase) & 0x3) ||
+ (hcd->rsrc_len &&
+ HC_LENGTH(capbase) + sizeof(struct xhci_op_regs) > hcd->rsrc_len)) {
+ xhci_err(xhci, "Invalid CAPLENGTH %#x (rsrc_len %#lx)\n",
+ HC_LENGTH(capbase), (unsigned long)hcd->rsrc_len);
+ return -ENODEV;
+ }
+ xhci->op_regs = hcd->regs + HC_LENGTH(capbase);
xhci->run_regs = hcd->regs +
(readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK);
/* Cache read-only capability registers */
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Forwarded: Re: #syz test (re-run after sandbox SYZFAIL)
2026-08-21 7:52 [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt syzbot
` (2 preceding siblings ...)
2026-08-21 13:15 ` Forwarded: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
@ 2026-08-21 13:40 ` syzbot
2026-08-21 14:14 ` Forwarded: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-08-21 13:40 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: Re: #syz test (re-run after sandbox SYZFAIL)
Author: erdaitianjiao@gmail.com
The previous run (job id 15d6fa25580000) failed with
SYZFAIL: posix_spawnp failed (errno 5: Input/output error)
but the kernel itself built and booted cleanly — no Oops / KASAN /
alignment fault from the xhci_halt path.
The crash is in the syzbot executor sandbox, not in the patch.
Please re-run using the patch you already have cached for this bug.
Thanks.
#syz test
^ permalink raw reply [flat|nested] 6+ messages in thread
* Forwarded: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup()
2026-08-21 7:52 [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt syzbot
` (3 preceding siblings ...)
2026-08-21 13:40 ` Forwarded: Re: #syz test (re-run after sandbox SYZFAIL) syzbot
@ 2026-08-21 14:14 ` syzbot
4 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2026-08-21 14:14 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup()
Author: erdaitianjiao@gmail.com
#syz test
xhci_hcd can be bound to arbitrary PCI devices via the
driver_override sysfs knob. When this happens to a device whose
MMIO registers are not xHCI capability registers,
xhci_gen_setup() reads CAPLENGTH from the foreign register
layout and uses it as a byte offset to compute op_regs.
A non-xHCI device can return a CAPLENGTH value that is
- not large enough to fit the capability register block, or
- not 4-byte aligned (e.g. the NVMe CAP register's low byte is
0xff, which becomes CAPLENGTH = 0xff).
The unaligned case is especially harmful on arm64: MMIO is
Device memory and Device-nGnRE accesses require natural
alignment, so readl(&op_regs->command) faults with an
alignment exception even when the address is within the
ioremapped region.
Validate CAPLENGTH in xhci_gen_setup() and fail probe with
-ENODEV if the value is smaller than 0x20 (capability registers
are 32 bytes per the xHCI spec), not 4-byte aligned, or leaves
no room for the operational register space within the mapped
region.
The run_regs_off read on the next line has the same shape, but
is not reachable on the xhci_halt code path and is left
untouched here.
Reproduced on a QEMU virt machine with a syzkaller repro that
unbinds the NVMe driver on 0000:00:02.0 and binds xhci_hcd via
driver_override. Before this patch the kernel Oopses and
panics; after, the probe is rejected cleanly (verified with 46
consecutive probe attempts, zero Oopses).
Reported-by: syzbot+c90273bf9017ef1462af@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=44c85514940262c7e2fad6f8fd0c07d8f2884154
Fixes: 552e0c4f12fe ("usb/xhci: move xhci_gen_setup() away from -pci.")
Signed-off-by: erdaitianjiao <erdaitianjiao@gmail.com>
---
drivers/usb/host/xhci.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 091c82ca8ee2..fb0075d0530f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -5432,7 +5432,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
*/
struct device *dev = hcd->self.sysdev;
int retval;
- u32 hcs_params1;
+ u32 hcs_params1, capbase;
/* Accept arbitrarily long scatter-gather lists */
hcd->self.sg_tablesize = ~0;
@@ -5453,8 +5453,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
mutex_init(&xhci->mutex);
xhci->main_hcd = hcd;
xhci->cap_regs = hcd->regs;
- xhci->op_regs = hcd->regs +
- HC_LENGTH(readl(&xhci->cap_regs->hc_capbase));
+ capbase = readl(&xhci->cap_regs->hc_capbase);
+ if (HC_LENGTH(capbase) < 0x20 ||
+ (HC_LENGTH(capbase) & 0x3) ||
+ (hcd->rsrc_len &&
+ HC_LENGTH(capbase) + sizeof(struct xhci_op_regs) > hcd->rsrc_len)) {
+ xhci_err(xhci, "Invalid CAPLENGTH %#x (rsrc_len %#lx)\n",
+ HC_LENGTH(capbase), (unsigned long)hcd->rsrc_len);
+ return -ENODEV;
+ }
+ xhci->op_regs = hcd->regs + HC_LENGTH(capbase);
xhci->run_regs = hcd->regs +
(readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK);
/* Cache read-only capability registers */
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-21 14:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21 7:52 [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt syzbot
2026-08-21 12:14 ` Forwarded: Re: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
2026-08-21 12:52 ` Forwarded: Re: [syzbot] [usb?] BUG: unable to handle kernel paging request in xhci_halt syzbot
2026-08-21 13:15 ` Forwarded: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
2026-08-21 13:40 ` Forwarded: Re: #syz test (re-run after sandbox SYZFAIL) syzbot
2026-08-21 14:14 ` Forwarded: [PATCH] usb: xhci: validate CAPLENGTH in xhci_gen_setup() syzbot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.