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=1796196129; b=C2ciIzr4C5O5NZXYV2Rf3qMp3VXkauMovRfBETSP81P2Eg7rbGsO0wNfFvjeB4NFppnS vsAdrs6Yo+DRs/UU7t4R7Yhb7ar3Lzg0nUv4Rd3RStFFbRPcoc/uxc7eDMZIvIl5Bc19b VxB90fFGGQVXAmpOlg0RTozHk3DjlBZ5FsvsUesqOpOMGehtY96W6v49i8cJrnJboZbdn x3cCvi20skDNJinhctZ/jPCdFhYjVV/TLGk07QgwMaNt52LpzrVxS1+QWPwL7Sa62Gb3e xLSD16Vvhh84iQ7MDXnkMrBVeVV/sNnrhHpXDl53OMImvxrTzubOYW2eEI3GkB8ZiMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796196129; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=rlS7hwY+Z80GZg1hLJzoFKEv8utVhBeUiw98CKq2fTE=; b=ufO48rnjyhDOL7LPoTWw1nosdlxl7+PaUSsKYHFgPplnJNnZmUNXR9BCS3VRMk0FlZ3o FPbEC5mzpSTcKXoLRWmzUByeZGngb/haq54WfPRy/n7IEd2+X/W63TjI3MxUk1VG7LLpI V3f57sSFFdpydnetXj6fGhcXkLk/p2/ikoJ9MtI41tAaT49jEr5QiM7bGZhgDwjOCUWst 69xrRhu3hOFqszP8GE4FvIlo38b5mvVW8mYpZWiuYcEklN2hnMFLBVz+vJtjIVHZvJez3 LjJHeItG2fKFFGh6cNrKI/d5TNsnc7Dzc388wKt17oZxTewE+XWB1XKJbjeEd7UMewA== 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=iuVDhtU7; 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 3D487606A333 for ; Wed, 2 Dec 2026 07:22:08 +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=iuVDhtU7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFEAC1F000C1; Wed, 2 Dec 2026 07:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796196128; bh=rlS7hwY+Z80GZg1hLJzoFKEv8utVhBeUiw98CKq2fTE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=iuVDhtU7T9VoZFBObRbj3DKXCyWd7ufnH1EI4jHTFLde4ef96w4hCIn2rbv4TX+Ig +3sRXGnfKbiYIIPWC/bd9NWzEn22X42GToJ1jteTA4lIk8AxQy3yV+JVfJZ33B270A zhJ5arTij2GSQD/SbPJbGLM/XrvyL4WuLsOhaLEIU1eduqSfKPPSnPFHZq54TIa2TF 4KBkSjsCKNARNeF1r92WuvqNo0b/lTH2w0PjBzwMKpjQnsjMdVIv4BCtAcNqCbn2Xq cnRcQOC3Hc18nGTafq8Kb8cUVgmi2nU8YMvCwPpQntb/v/fUWBplC7qkFtQ6iq+16Q 0IHxDeGXSjL3g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] usb: gadget: uvc: compute isoc payload size at encode time Reply-To: sashiko-reviews@lists.linux.dev To: "Keisuke Tsukuda" Cc: =?utf-8?b?bGludXgtdXNiQHZnZXIua2VybmVsLm9yZw==?= In-Reply-To: <20261202071552.5481-1-tkdkei@outlook.jp> References: <20261202071552.5481-1-tkdkei@outlook.jp> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 07:22:08 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > uvc_buffer_prepare() calculates req_payload_size when userspace queues a > buffer. Before the first STREAMON, reqs_per_frame is zero, so the payload > size falls back to max_req_size. After the host selects streaming alt 1, > this fallback can exceed the isochronous request size later allocated at > STREAMON. If QBUF occurs before alt 1, max_req_size is still zero; the > copying encoder then subtracts the UVC header length from a zero payload > size. Either case can make it copy past the request buffer. A buffer > queued before a later STREAMON can also use the previous stream's request > layout because reqs_per_frame and req_size are not reset. >=20 > On a Raspberry Pi CM4, a 320x180 YUYV stream with a 512-byte stored > payload and 228-byte requests produced list_del corruption and an Oops. >=20 > Calculate the payload size in uvcg_video_pump() instead, after the > current request count and size have been set, and remove the prepare-time > calculation. Bound the result by req_size. Round up with a quotient and > remainder, then cap the data and header lengths before adding them to > avoid 32-bit overflow. >=20 > Fixes: 98ad03291560 ("usb: gadget: uvc: set req_length based on payload b= y nreqs instead of req_size") > Fixes: 2edc1acb1a25 ("usb: gadget: uvc: fix req_payload_size calculation") > Reported-by: Farhad Alemi > Closes: https://lore.kernel.org/r/CA+0ovCh5uOgB5CQm5eqZFoWE11Uqs4=3Dt4yES= -7E1_oH60HtaKw@mail.gmail.com > Cc: stable@vger.kernel.org > Signed-off-by: Keisuke Tsukuda Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202071552.5481= -1-tkdkei@outlook.jp?part=3D1