From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796540232; b=2G1tArO9FbAs/f+GoZ3QA8C590uicVkDeiCBuYx9gG6eobFQOSXtv4pHD2EK+t8PakcG cFsUZhVgOGVVLb78PXjQLrsJl23nbq18RDX8akIDbN9u+vyFoI8HYGp/1YwrTtUxZyBvT 0TcNDcQIQSUItcvxRr7pykIk390gn6OUw2CuF3Fa30HsVHamqEuPDzrTNT1+5OTegjBAv raDUtv81QDaZXKc8O9HTIN0SWi8qb7BZBnzamVJEjLAAaycFKky8V4bPubydtb3grUfBn RuXURhDBVxHK93PJA7hS17j0RSFpbG72HC6iQj8fE3S9ZPnStnKxbp0Q+RrOSOHXXFQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796540232; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=ij1yePU8IrBU0T6U8LfN3HZdOKUsu2mG5hUoWymuQ4o=; b=sb92Wqlut7Dvz3ulRWsLb1GpK88TOKfKCOKU+Ull1KgxrPyznUCiFBnY2oGyLERw7axR AqSQVO47Y0Cw8hk6hT8KGaKSsbrkWFJYCnR8iq6NmfmG/9dPS55iduJbcPfzjNP3xXBUg oVO7ovppBsLtNsOQZB8BJdOrh9JWCxfZuG2r/49/i2WRwvkDgOhiSaczGuqG+RUMKsc/3 YQnQBCW7D8d8v2ivXxg3jW1wKIZASCv+HODIpEw41ZYkuIR1+1cmwEUpcf4snePDRx5kG R+O+sNzokcueRac7R7VysOfG2BojxeLD8Y6RUqbraHBg9oeFIZ9xxw4gxGLP7Bc48Fg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=G5AVZdml; arc=none smtp.remote-ip=74.125.82.179 Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 398E1606A321 for ; Sun, 6 Dec 2026 06:57:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 398E1606A321 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=G5AVZdml Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-38747f42472so3765242eec.0 for ; Sat, 05 Dec 2026 22:57:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796540230; x=1797145030; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ij1yePU8IrBU0T6U8LfN3HZdOKUsu2mG5hUoWymuQ4o=; b=G5AVZdmlvO6NCKXBcnq0StUswJvdM60puNBAhRJ8pW9JDdQbqku4SHoAgqMN2ytVSD gceJ9x9tOtcHxw7lGmhIIPqNv7Ixq9Aq/KxXiv82u3mPJLCTwCkgZuSclWBn2qo+K4KJ FebArFTXmeBkrIz3zBYzFHZGGfS2Nf68RBnADkl9uJR568ZyqF2o8Qpt2Xum9FHVyXv3 x9Hs8uwBfP7IPcNNWLpVcCiWCcc5qJNlfwgjYFwleMp7DKX1Ptt0/FJ8ifVY3XxMWEHO jmEpl7lqXeizboP6XlDSCDSaJXs5Lap+syqJFeZekQdX32HNAodZ7bgiD22mQqhTzxk+ QPgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796540230; x=1797145030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ij1yePU8IrBU0T6U8LfN3HZdOKUsu2mG5hUoWymuQ4o=; b=pyZuEBY1Bh9FOrSF8Cc4kcZk7uNmbcZF/41tnD3i8JxuIQ70Wi/NEd90P32wEwnwvo GNVwnaskjnBgynUzm4sjkpXZLtKeNh8Dci7e94yxIRuSGovWU/742puPAU08H0PONGD9 Q3NbD66Zozud7sz3C0cDJ4UeLUY4BraCmxePwFcbhcYI2oLgphT22m9Syp7ymf1x5p/N dgm5toJPshLVN2mlh03rSYNzY5BFPe2WYxf0y/MJ7Lh3i1YulQKj2uQeeSueUcdwOfWE +eTz/EYHCe3RRtZmefeDfhJrVgBGhRdPBe1rzpYZhEOvOqUNlKC6t9nODonwjEkjqcTX OfCA== X-Forwarded-Encrypted: i=1; AL+hErFZYZVdETSybSqt1SZ6JB39VnyzI6P3mOb7Tq/KH1L+2k3TvWqzSZZ3VO8P09ALrw+ravI0+Q4=@vger.kernel.org X-Gm-Message-State: AB4q+uHuFGtnpHJxACITBXrLh2R+mBJEaC77YCh3UVCSxyjPya/MnhUQ 3gebmscfXH6tgOX3347TjN9qZFZXcTs+pU3HDMsc/o7n9pZdBWkWF53i X-Gm-Gg: AZFdTZe0BzDYQL97Hef1AKm9LkwsYoJ1N+SGjC5EfpwRCkSrTTXTz1etAGZMn3bfKV5 wXmYa9NNYPCddpbfbDp/MI0yD+GSJ+v6TSMEcZKP+V27y/0zZC44GQIbTpXcol9JhZQNyotud6U wtGIJdKnIpkGfg07yURlfVZVra6A1n6zMPREaC9/gvTaWRfdfSC1/fx14JWC0Xj5+bAc1CNemMp k8/ifZAXaqglNP8CwqNVcI2cC3kIzEVKgKIJzR5r7FyunliCy6OqF+SVUK3z94gbURXDQ7P/aHT 0DfFS0hQPXzgDS6aKNUEC7oA6AWEPXf0HEuKGzckesgGg6Qsjb13GejNRtHYf2f/SOkrdyzPV6P 3L3msQDN4AVogymPprG18O8C18uLh2iXDo1TxbbnINDfIIH10yCvGepmY5zTV0p9yvDHo/vaBzk XphrUBfvv8nct723+7Uk+JbkdcAfSBHBWfxHU5t/GMm+PWVL6QDxjiO9d1Kc31g8oJa7NM4iDxr tYLio9MKMqzEApjgNjoTwFzPmjCZPejw9CRYNYjHDvnfHDLfI4HsQ+BtOKTS6fEYtp4Ing20EnL I7AGjNN1P/ipow06Mh+TAURTHK+dmLn9H5pVGcEdZ5Zmch4YlCED1g== X-Received: by 2002:a05:693c:69cd:b0:384:7b4c:8564 with SMTP id 5a478bee46e88-3875222a38emr5689244eec.41.1796540230274; Sat, 05 Dec 2026 22:57:10 -0800 (PST) Received: from ico.. (softbank060117076056.bbtec.net. [60.117.76.56]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521e5626sm24573790eec.17.2026.12.05.22.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 22:57:09 -0800 (PST) From: Daisuke Yamane To: Takashi Iwai , Jaroslav Kysela Cc: linux-sound@vger.kernel.org, Daisuke Yamane , stable@vger.kernel.org Subject: [PATCH v2 1/2] ALSA: usb-audio: Don't read past the packet with pkt_offset_adj Date: Sun, 6 Dec 2026 15:56:51 +0900 Message-ID: <20261206065652.51981-2-yamane07ynct@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261206065652.51981-1-yamane07ynct@gmail.com> References: <20261206065652.51981-1-yamane07ynct@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit retire_capture_urb() starts the copy pkt_offset_adj bytes into each packet but derives the number of frames from the full actual_length, so the copy ends pkt_offset_adj bytes after the received data. The packets of a URB lie back to back in transfer_buffer, so for the last packet of a URB that fills its slot, memcpy() reads past the end of the buffer. A device can send such a packet regardless of the layout that its quirk expects. Subtract pkt_offset_adj from the byte count, as is already done for stream_offset_adj. A packet shorter than the offset gives no frames. For a packet of the offset followed by whole frames, the frame count is unchanged when a frame is larger than the offset; otherwise offset / frame size frames (rounded down) past the received data were copied, which this drops. This was found by the Sashiko AI review of a patch that adds a second user of pkt_offset_adj; the change and this description were prepared with the help of an AI coding assistant. Fixes: 1539d4f82ad5 ("ALSA: usb: Add quirk for 192KHz recording on E-Mu devices") Cc: stable@vger.kernel.org Signed-off-by: Daisuke Yamane --- Tested only on the Yamaha ZG02 together with patch 2/2 (see there); not tested on E-Mu hardware. sound/usb/pcm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 57a2649..d88ef29 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -1343,6 +1343,8 @@ static void retire_capture_urb(struct snd_usb_substream *subs, i, bytes, urb->iso_frame_desc[i].length); continue; } + /* the bytes skipped by pkt_offset_adj are not frames */ + bytes -= min(subs->pkt_offset_adj, bytes); if (subs->stream_offset_adj > 0) { unsigned int adj = min(subs->stream_offset_adj, bytes); cp += adj; -- 2.43.0