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=1796392372; b=iM3s5zB4EzQuHZ9FheYd4faZjis5FrXMsttoItAx7xoHT72WtEEaStFupppbN+pbd7jI L+V04ubq9vGzshAdttpDLcKnG6KqlKNxyh3vR3tL3TH7qNqA14mYvFFVKvpusZoRLyGg3 +KUwrJbACh0iUKovMT1owNkq7q7IIUecHmlIGABdhFepdZig9lVH9tkH+V7+p78vxLjt6 H5v6RUIutKv9FGszKHvhAE2Eb2F/zgXxxEX3sWwbvrNDUS9W/jQGPrH7RESXzy/+AwxBF ZokitkkaOyxLW/RCMO5OrjmfyOxV7lEZxbv7oiqF0Eee3Bbhr+Zayy3lWKlSFCZ7O2A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796392372; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=yj+iohx3fEXRDbx2rADjH1n0o0zPahhLKcgO3S80gno=; b=y3L9ilrt0PuR/QCAzVCNcrtsBzykgs2DsDUrmjLnuuMb/kO6ziM3+aD42DqxBZqa2hXQ 6gD4+lfHINAhn8MLj7b1Dhx5PxRRKvSEou1VOFawTG4XQKwYjmU/aH93o6JPF/Z/75eqN 7iHWqOgkDWElEU0BnEMiOA2AHhGUknAL/ll3+M+meOPovptpKartcwJkaYKZ1+BScZRnM lDzlK0HHpRLPTuk9rCBUsQgbxQBFy+i6Mk9dxlyE2zkxkYPt0+CtO5seq0VIXmptZArrI yTaOu6DvaMa6SQ51xAjJL29GOZvV3DyJbQLzTTO/wZH959uQxxoY43gthKhlGty7tXA== 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=gQ6yQoHV; 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 58EB4606A33D for ; Fri, 4 Dec 2026 13:52:52 +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=gQ6yQoHV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AD681F00937; Fri, 4 Dec 2026 13:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796392372; bh=yj+iohx3fEXRDbx2rADjH1n0o0zPahhLKcgO3S80gno=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=gQ6yQoHVOoJkrDNln1tSC9BS8yIXQLOO0icnUY5NnjvGACr1dXUXPcJQxbZiK0kKy 99W3btoYWvw5r4mmOeF7HSH/i1RT6IFAFwWSJDnG8ieSwg+dwiZO3Y/oNxlRVM8xXA xteGEfysHwsuP3FTD2ycdKRmXwlzasClpZmgh3LnaXPym+gDOQxn36j6JQwMi39ShH BPetwFLE4ncj4scVk85bz/zkhRthDoc1rbUqhJo5bSpNVOYg2fcLFPWglsURaIo0bT YPqDrfE/VrLqki7Rfn3msmCfkSeogNYq6crnWxxOQsyF3K66qzBzCVPXOvCv4XBG+X b++FKxOe4bHdQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] ALSA: usb-audio: Skip packet header in Yamaha ZG02 capture stream Reply-To: sashiko-reviews@lists.linux.dev To: "Daisuke Yamane" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261204133429.247377-1-yamane07ynct@gmail.com> References: <20261204133429.247377-1-yamane07ynct@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 13:52:51 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ALSA: usb-audio: OOB read in retire_capture_urb() with pkt_offset_adj -- commit 4f42e1ac4fec821d619625b40ff2e9b8d0f517f2 Author: Daisuke Yamane ALSA: usb-audio: Skip packet header in Yamaha ZG02 capture stream This commit adds snd_usb_set_pkt_offset_quirk() and calls it on every snd_usb_pcm_prepare() to set subs->pkt_offset_adj =3D 8 for Yamaha ZG02 capture streams, skipping the 8-byte header at the start of each isochronous packet. > diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c > index 0694c02558fea..ab149b22778fb 100644 > --- a/sound/usb/quirks.c > +++ b/sound/usb/quirks.c > @@ -2138,6 +2138,23 @@ void snd_usb_set_format_quirk(struct snd_usb_subst= ream *subs, > } > } > =20 > +/* > + * Called on every prepare. snd_usb_set_format_quirk() runs only when the > + * data endpoint is newly prepared, which is not the case for a capture > + * endpoint that a running playback stream already prepared as its > + * implicit feedback source. > + */ > +void snd_usb_set_pkt_offset_quirk(struct snd_usb_substream *subs) > +{ > + switch (subs->stream->chip->usb_id) { > + case USB_ID(0x0499, 0x1516): /* Yamaha ZG02 */ > + /* capture packets: [u32 seq][u32 len] frames [u32 seq] */ > + if (subs->direction =3D=3D SNDRV_PCM_STREAM_CAPTURE) > + subs->pkt_offset_adj =3D 8; > + break; > + } > +} [Severity: Medium] Can setting subs->pkt_offset_adj =3D 8 cause an out-of-bounds read past urb->transfer_buffer in retire_capture_urb()? retire_capture_urb() advances cp by subs->pkt_offset_adj, but unlike subs->stream_offset_adj, it never checks that bytes >=3D subs->pkt_offset_a= dj or subtracts subs->pkt_offset_adj from bytes before computing frames and copying into runtime->dma_area: sound/usb/pcm.c:retire_capture_urb() { ... cp =3D (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offs= et + subs->pkt_offset_adj; ... bytes =3D urb->iso_frame_desc[i].actual_length; if (unlikely(bytes > urb->iso_frame_desc[i].length)) { ... continue; } ... frames =3D bytes / stride; if (!subs->txfr_quirk) bytes =3D frames * stride; ... memcpy(runtime->dma_area + oldptr, cp, bytes); } data_ep_set_params() allocates urb->transfer_buffer to maxsize * u->packets with no trailing padding, and prepare_inbound_urb() packs the packets back-to-back. On the last packet, a full-length transfer where (actual_length / stride) * stride + 8 > length (such as 144 bytes with stride 16) causes memcpy() to read up to 8 bytes past urb->transfer_buffer, which can fault or copy adjacent memory into runtime->dma_area. Dropping packets with bytes <=3D subs->pkt_offset_adj and subtracting subs->pkt_offset_adj from bytes before computing frames in retire_capture_urb() would prevent the over-read while keeping ZG02 frame counts unchanged ((108 - 8) / 16 =3D 6, (124 - 8) / 16 =3D 7). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204133429.2473= 77-1-yamane07ynct@gmail.com?part=3D1