From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Alan Stern <stern@rowland.harvard.edu>,
Oliver Neukum <oneukum@suse.com>,
syzbot+8693a0bb9c10b554272a@syzkaller.appspotmail.com
Subject: [PATCH 5.10 085/108] USB: core: Fix duplicate endpoint bug by clearing reserved bits in the descriptor
Date: Tue, 16 Jul 2024 17:31:40 +0200 [thread overview]
Message-ID: <20240716152749.248697606@linuxfoundation.org> (raw)
In-Reply-To: <20240716152745.988603303@linuxfoundation.org>
5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <stern@rowland.harvard.edu>
commit a368ecde8a5055b627749b09c6218ef793043e47 upstream.
Syzbot has identified a bug in usbcore (see the Closes: tag below)
caused by our assumption that the reserved bits in an endpoint
descriptor's bEndpointAddress field will always be 0. As a result of
the bug, the endpoint_is_duplicate() routine in config.c (and possibly
other routines as well) may believe that two descriptors are for
distinct endpoints, even though they have the same direction and
endpoint number. This can lead to confusion, including the bug
identified by syzbot (two descriptors with matching endpoint numbers
and directions, where one was interrupt and the other was bulk).
To fix the bug, we will clear the reserved bits in bEndpointAddress
when we parse the descriptor. (Note that both the USB-2.0 and USB-3.1
specs say these bits are "Reserved, reset to zero".) This requires us
to make a copy of the descriptor earlier in usb_parse_endpoint() and
use the copy instead of the original when checking for duplicates.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: syzbot+8693a0bb9c10b554272a@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-usb/0000000000003d868e061bc0f554@google.com/
Fixes: 0a8fd1346254 ("USB: fix problems with duplicate endpoint addresses")
CC: Oliver Neukum <oneukum@suse.com>
CC: stable@vger.kernel.org
Link: https://lore.kernel.org/r/205a5edc-7fef-4159-b64a-80374b6b101a@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/core/config.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -291,6 +291,20 @@ static int usb_parse_endpoint(struct dev
if (ifp->desc.bNumEndpoints >= num_ep)
goto skip_to_next_endpoint_or_interface_descriptor;
+ /* Save a copy of the descriptor and use it instead of the original */
+ endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints];
+ memcpy(&endpoint->desc, d, n);
+ d = &endpoint->desc;
+
+ /* Clear the reserved bits in bEndpointAddress */
+ i = d->bEndpointAddress &
+ (USB_ENDPOINT_DIR_MASK | USB_ENDPOINT_NUMBER_MASK);
+ if (i != d->bEndpointAddress) {
+ dev_notice(ddev, "config %d interface %d altsetting %d has an endpoint descriptor with address 0x%X, changing to 0x%X\n",
+ cfgno, inum, asnum, d->bEndpointAddress, i);
+ endpoint->desc.bEndpointAddress = i;
+ }
+
/* Check for duplicate endpoint addresses */
if (config_endpoint_is_duplicate(config, inum, asnum, d)) {
dev_notice(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
@@ -308,10 +322,8 @@ static int usb_parse_endpoint(struct dev
}
}
- endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints];
+ /* Accept this endpoint */
++ifp->desc.bNumEndpoints;
-
- memcpy(&endpoint->desc, d, n);
INIT_LIST_HEAD(&endpoint->urb_list);
/*
next prev parent reply other threads:[~2024-07-16 15:45 UTC|newest]
Thread overview: 115+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 15:30 [PATCH 5.10 000/108] 5.10.222-rc1 review Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 001/108] drm/lima: fix shared irq handling on driver remove Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 002/108] media: dvb: as102-fe: Fix as10x_register_addr packing Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 003/108] media: dvb-usb: dib0700_devices: Add missing release_firmware() Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 004/108] IB/core: Implement a limit on UMAD receive List Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 005/108] scsi: qedf: Make qedf_execute_tmf() non-preemptible Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 006/108] crypto: aead,cipher - zeroize key buffer after use Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 007/108] drm/amdgpu: Initialize timestamp for some legacy SOCs Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 008/108] drm/amd/display: Check index msg_id before read or write Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 009/108] drm/amd/display: Check pipe offset before setting vblank Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 010/108] drm/amd/display: Skip finding free audio for unknown engine_id Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 011/108] media: dw2102: Dont translate i2c read into write Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 012/108] sctp: prefer struct_size over open coded arithmetic Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 013/108] firmware: dmi: Stop decoding on broken entry Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 014/108] Input: ff-core - prefer struct_size over open coded arithmetic Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 015/108] net: dsa: mv88e6xxx: Correct check for empty list Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 016/108] media: dvb-frontends: tda18271c2dd: Remove casting during div Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 017/108] media: s2255: Use refcount_t instead of atomic_t for num_channels Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 018/108] media: dvb-frontends: tda10048: Fix integer overflow Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 019/108] i2c: i801: Annotate apanel_addr as __ro_after_init Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 020/108] powerpc/64: Set _IO_BASE to POISON_POINTER_DELTA not 0 for CONFIG_PCI=n Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 021/108] orangefs: fix out-of-bounds fsid access Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 022/108] kunit: Fix timeout message Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 023/108] powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#" Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 024/108] bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 025/108] jffs2: Fix potential illegal address access in jffs2_free_inode Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 026/108] s390/pkey: Wipe sensitive data on failure Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 027/108] UPSTREAM: tcp: fix DSACK undo in fast recovery to call tcp_try_to_open() Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 028/108] tcp_metrics: validate source addr length Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 029/108] wifi: wilc1000: fix ies_len type in connect path Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 030/108] bonding: Fix out-of-bounds read in bond_option_arp_ip_targets_set() Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 031/108] selftests: fix OOM in msg_zerocopy selftest Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 032/108] selftests: make order checking verbose " Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 033/108] inet_diag: Initialize pad field in struct inet_diag_req_v2 Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 034/108] nilfs2: fix inode number range checks Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 035/108] nilfs2: add missing check for inode numbers on directory entries Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 036/108] mm: optimize the redundant loop of mm_update_owner_next() Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 037/108] mm: avoid overflows in dirty throttling logic Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 038/108] Bluetooth: qca: Fix BT enable failure again for QCA6390 after warm reboot Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 039/108] can: kvaser_usb: Explicitly initialize family in leafimx driver_info struct Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 040/108] fsnotify: Do not generate events for O_PATH file descriptors Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 041/108] Revert "mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again" Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 042/108] drm/nouveau: fix null pointer dereference in nouveau_connector_get_modes Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 043/108] drm/amdgpu/atomfirmware: silence UBSAN warning Greg Kroah-Hartman
2024-07-16 15:30 ` [PATCH 5.10 044/108] mtd: rawnand: Bypass a couple of sanity checks during NAND identification Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 045/108] bnx2x: Fix multiple UBSAN array-index-out-of-bounds Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 046/108] bpf, sockmap: Fix sk->sk_forward_alloc warn_on in sk_stream_kill_queues Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 047/108] ima: Avoid blocking in RCU read-side critical section Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 048/108] media: dw2102: fix a potential buffer overflow Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 049/108] i2c: pnx: Fix potential deadlock warning from del_timer_sync() call in isr Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 050/108] ALSA: hda/realtek: Enable headset mic of JP-IK LEAP W502 with ALC897 Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 051/108] nvme-multipath: find NUMA path only for online numa-node Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 052/108] nvme: adjust multiples of NVME_CTRL_PAGE_SIZE in offset Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 053/108] platform/x86: touchscreen_dmi: Add info for GlobalSpace SolT IVW 11.6" tablet Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 054/108] platform/x86: touchscreen_dmi: Add info for the EZpad 6s Pro Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 055/108] nvmet: fix a possible leak when destroy a ctrl during qp establishment Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 056/108] kbuild: fix short log for AS in link-vmlinux.sh Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 057/108] nilfs2: fix incorrect inode allocation from reserved inodes Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 058/108] mm: prevent derefencing NULL ptr in pfn_section_valid() Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 059/108] filelock: fix potential use-after-free in posix_lock_inode Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 060/108] fs/dcache: Re-use value stored to dentry->d_flags instead of re-reading Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 061/108] vfs: dont mod negative dentry count when on shrinker list Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 062/108] tcp: fix incorrect undo caused by DSACK of TLP retransmit Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 063/108] octeontx2-af: Fix incorrect value output on error path in rvu_check_rsrc_availability() Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 064/108] net: lantiq_etop: add blank line after declaration Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 065/108] net: ethernet: lantiq_etop: fix double free in detach Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 066/108] ppp: reject claimed-as-LCP but actually malformed packets Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 067/108] ethtool: netlink: do not return SQI value if link is down Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 068/108] udp: Set SOCK_RCU_FREE earlier in udp_lib_get_port() Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 069/108] net/sched: Fix UAF when resolving a clash Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 070/108] s390: Mark psw in __load_psw_mask() as __unitialized Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 071/108] ARM: davinci: Convert comma to semicolon Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 072/108] octeontx2-af: fix detection of IP layer Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 073/108] tcp: use signed arithmetic in tcp_rtx_probe0_timed_out() Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 074/108] tcp: avoid too many retransmit packets Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 075/108] net: ks8851: Fix potential TX stall after interface reopen Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 076/108] USB: serial: option: add Telit generic core-dump composition Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 077/108] USB: serial: option: add Telit FN912 rmnet compositions Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 078/108] USB: serial: option: add Fibocom FM350-GL Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 079/108] USB: serial: option: add support for Foxconn T99W651 Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 080/108] USB: serial: option: add Netprisma LCUK54 series modules Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 081/108] USB: serial: option: add Rolling RW350-GL variants Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 082/108] USB: serial: mos7840: fix crash on resume Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 083/108] USB: Add USB_QUIRK_NO_SET_INTF quirk for START BP-850k Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 084/108] usb: gadget: configfs: Prevent OOB read/write in usb_string_copy() Greg Kroah-Hartman
2024-07-16 15:31 ` Greg Kroah-Hartman [this message]
2024-07-16 15:31 ` [PATCH 5.10 086/108] hpet: Support 32-bit userspace Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 087/108] nvmem: meson-efuse: Fix return value of nvmem callbacks Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 088/108] ALSA: hda/realtek: Enable Mute LED on HP 250 G7 Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 089/108] ALSA: hda/realtek: Limit mic boost on VAIO PRO PX Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 090/108] libceph: fix race between delayed_work() and ceph_monc_stop() Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 091/108] wireguard: allowedips: avoid unaligned 64-bit memory accesses Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 092/108] wireguard: queueing: annotate intentional data race in cpu round robin Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 093/108] wireguard: send: annotate intentional data race in checking empty queue Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 094/108] x86/retpoline: Move a NOENDBR annotation to the SRSO dummy return thunk Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 095/108] efi: ia64: move IA64-only declarations to new asm/efi.h header Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 096/108] ipv6: annotate data-races around cnf.disable_ipv6 Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 097/108] ipv6: prevent NULL dereference in ip6_output() Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 098/108] bpf: Allow reads from uninit stack Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 099/108] nilfs2: fix kernel bug on rename operation of broken directory Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 100/108] arm64/bpf: Remove 128MB limit for BPF JIT programs Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 101/108] i2c: rcar: bring hardware to known state when probing Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 102/108] i2c: mark HostNotify target address as used Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 103/108] i2c: rcar: Add R-Car Gen4 support Greg Kroah-Hartman
2024-07-16 15:31 ` [PATCH 5.10 104/108] i2c: rcar: reset controller is mandatory for Gen3+ Greg Kroah-Hartman
2024-07-16 15:32 ` [PATCH 5.10 105/108] i2c: rcar: introduce Gen4 devices Greg Kroah-Hartman
2024-07-16 15:32 ` [PATCH 5.10 106/108] i2c: rcar: ensure Gen3+ reset does not disturb local targets Greg Kroah-Hartman
2024-07-16 15:32 ` [PATCH 5.10 107/108] i2c: rcar: clear NO_RXDMA flag after resetting Greg Kroah-Hartman
2024-07-16 15:32 ` [PATCH 5.10 108/108] i2c: rcar: fix error code in probe() Greg Kroah-Hartman
2024-07-16 18:09 ` [PATCH 5.10 000/108] 5.10.222-rc1 review Florian Fainelli
2024-07-16 20:11 ` Pavel Machek
2024-07-16 20:47 ` Naresh Kamboju
2024-07-17 6:22 ` Greg Kroah-Hartman
2024-07-16 22:27 ` Mark Brown
2024-07-17 3:43 ` Dominique Martinet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240716152749.248697606@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=oneukum@suse.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=syzbot+8693a0bb9c10b554272a@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).