From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796185141; b=hoi/aAGumqzbIZkU/r0msTqxKpJaXYRaGlbk/ZcfUBqkX9SiKybezGdkSqzgIxd192mC Yhpnusel2CqOzcPsl3LMYZkV0S3SRxt5dnS+TT/1SIrQfSDO/bttNjkrdteU0J58a3G6K TgQwJRmiEu3JEMeNGv1emqApJ4+SwgoR6iwpeEn8Qw7oiSbSWeb38VOVdg7ynohkCc0X6 t5AzkRuF167ZGlNUSmS6yLb7qgr9QAX2+qvymvogV4s9//a5y9VMaphHmO5b9352f8zL1 WE77UQrlj3i+6Ki2GCXZ44Hp4kjcdR5IlBqMzuQQ7IHPuCG4Y8OiQlK7dqfCRAcgwhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796185141; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Boza9wpadxaN32mJBITHMkQaL7ugC2IFccjzqHFB4h0=; b=WG4isKoULBG9lZlSkowH1k7h5sstGnZMee793Sx8lQdZ9oszujMPI4hlYGuYSFSDDC6Y xgT1W7ZT2QmXzC2uEPnbvUkGfFZt8hRmyrE1rGYtir+SXnZEZ3fgMZsRIo6+KghwLV5qO Rwwh0HKNyrj00vwKpju/kaUvx4CuAxBo7U05lJ5uaUjpKlAF/Ap7ORRWCtxg9hXZvsxNh j9UAnwJiAABsMJy83oLxhHpdtGOmeK/KSmsD6arEG2R7Qh33eNJ3rkLVfWQXABK1DeWk8 scZ2+D0+5uAcXbRnK+48j+QVRZCBrCMIrHgTE+trLJB5AtB9YBNbmPGep8OqsDq1rHA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AMx9Wpi1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4EEC606A31A for ; Wed, 2 Dec 2026 04:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AMx9Wpi1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 516021F00896; Wed, 2 Dec 2026 04:19:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796185141; bh=Boza9wpadxaN32mJBITHMkQaL7ugC2IFccjzqHFB4h0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=AMx9Wpi1wevS3iXezyYJV61jH/ZSri72hUY+dvKWbHHuwVkMzzFP0f4sSwR9nPK48 2g79h3db8tW1ujMKCVactLQOWVEjy+VGCL84855cyjhSThRqZAhKT7LKqYw7ctfIPa owFED4BSLH3wH9Z2zvuSVT23gt1zhuZyRpEBgySeILS0DI3nX9JyTzaRYKHMx7l40g 6DaEUtIzYPDBIWd/1y1x47sXCE0fDOhsib7h/r5YTz+9cUvAHtZ++OPN6i2fFJx7cQ Mye8ErAbO9TZhNr+QWnH+y4FzKsR9PzJpJbVVffLP0litYRofV9Rr/d2n5+2jsusDf 84NvWW3LdmkwA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] usb: core: reject SG URBs longer than their scatterlist Reply-To: sashiko-reviews@lists.linux.dev To: "Artem Dinaburg" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261202041214.97186-1-artem@trailofbits.com> References: <20261202041214.97186-1-artem@trailofbits.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 04:19:00 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > A bulk or interrupt URB that uses a scatterlist can request more bytes > than the scatterlist covers. usb_sg_init() copies its caller's length > into transfer_buffer_length without comparing it to the scatterlist, > and usb_submit_urb() does not check it either. xhci-hcd queues TRBs > until the requested length is reached; after the final entry it > continues from the last DMA address and length, so the controller > transfers data outside the mapping. A USB device can cause this > mismatch. >=20 > Reject such URBs in usb_submit_urb() so that every HCD is covered. The > existing scatter-gather check is skipped when the bus has no SG > constraint, as is the case for xHCI, so sum the entry lengths for every > SG URB and keep the maxpacket check conditional. >=20 > Found and fixed with AI assistance. >=20 > Suggested-by: Alan Stern > Fixes: 86065c2719a5 ("xhci: don't rely on precalculated value of needed t= rbs in the enqueue loop") > Cc: stable@vger.kernel.org > Signed-off-by: Artem Dinaburg Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202041214.9718= 6-1-artem@trailofbits.com?part=3D1