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=1796491746; b=D8oheg9XnHQc7DxB7tquA/I5CvhRnp9mFTlGJ+F7XUfRHf7xyDec1R+C8fMqcbm27krq V9x6Ld7yZBroBTaAUYx+Rqg9ueD6xwwlsiiAD0nSH1ut262l4DVQ5o90vLkbgvnIiCKaR /Qob++a61D/tLhjhxoeOI9EtKkN/Zsd0Ai9TV346j/FrVkJgqYAao77o8fU3lF2Q3U7Fx dPRteZyaIHPHc1ZIKlEOP5K+hIzqRpbn0/non/sYx8Rl0rKIX2t+fu50y2rDIHpq4nfkD UkrGiD54FQ2nVgZi6GZBhDjg3CJX93mBULmYdlEwutaeB9fYk90559VgSdx+ptXbZcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796491746; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=hR3oRlmwqA1kEpueRzT99+ZlWIKaPxuwvWVi2URPJRU=; b=vEVua3dY5d3cTgz3ZAjY7qQ4XdUA28SjQ/+00sKxf/1ipZw8mhDe22JLNTtiB70WoNWp IlTK95Kd0Z2JLXXCA0LIJjJwGIPM3SjIN2v3c9ZX2HF1TOdi3pSjXhJFM6ajVgr4JFwAY 1woZXHrtqH7awPp8r3YeNfW/IqIdLEtmryhP3dW+cHxCUesmHJcbibK8QxyKUQc+FG9wc 05DBtupiJyU4DfH+/ALv2uHUJVg/ErNbFyiGNSJYVL6byVGWonhX1AmMcRymkga59YWvC ckQ5yBu0m+z9p6tRYavorvcGcva83Yr3VfaEwKeAPrP3m/L8CgwmKmk2aYUa9JfmVCA== 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=RirzQGfF; 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 1759E606A31F for ; Sat, 5 Dec 2026 17:29:05 +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=RirzQGfF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FFA41F00A07; Sat, 5 Dec 2026 17:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796491745; bh=hR3oRlmwqA1kEpueRzT99+ZlWIKaPxuwvWVi2URPJRU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=RirzQGfFqzzsWgK+WQNqwbPamp73JWqzvsP2rzN1QTR3HD/GWqjmIAh+l+GAzsPvh fOrJ76bhstmBVcYgBIiDoRuV89fK3d4b1vZD+un85vQiHd9KJ7nIhR/MV65j3d+f8i pjuMqBCSM5kGf0+UnNgbHLUirCyJj1GZvvrv4Q1dfh5DYp/r9osqP4OnjWS1Ubwexr 5AORwrJtA6a+lAjQKcPj4+p9PWr3rXvVn9MDWYiPdApICr6EjaR15Ac9ZVjnF9ddoB UgyMuX0nsVCJQwSJ1UCWOJIFQBJMJqxej8VhoPjZPJFDdH+oA3owjQKsz9xKaqzFOW gCtQOEBBiyN2w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 3/3] ALSA: oxfw: bound the stream format entries to the response length Reply-To: sashiko-reviews@lists.linux.dev To: "Maoyi Xie" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261206-firewire-avc-bounds-v4-3-d90e91e0088e@gmail.com> References: <20261206-firewire-avc-bounds-v4-0-d90e91e0088e@gmail.com> <20261206-firewire-avc-bounds-v4-3-d90e91e0088e@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 17:29:05 +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: - [Low] ALSA: oxfw: duplicate AM824 parsing logic in check_and_parse_format() -- commit 09d04fde4586e79a8721a40f8fc2146df6f65643 Author: Maoyi Xie ALSA: oxfw: bound the stream format entries to the response length This commit splits stream format parsing into check_and_parse_format(), which checks that the two-byte format entries fit within the response length for live responses, and snd_oxfw_stream_parse_format(), which parses cached formats. > diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw= -stream.c > index 5e36d7153a7b6..cc61ad1ee3071 100644 > --- a/sound/firewire/oxfw/oxfw-stream.c > +++ b/sound/firewire/oxfw/oxfw-stream.c [ ... ] > @@ -548,8 +551,8 @@ int snd_oxfw_stream_get_current_formation(struct snd_= oxfw *oxfw, > * in AV/C Stream Format Information Specification 1.1 (Apr 2005, 1394TA) > * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005 > */ > -int snd_oxfw_stream_parse_format(const u8 *format, > - struct snd_oxfw_stream_formation *formation) > +static int check_and_parse_format(const u8 *format, unsigned int len, > + struct snd_oxfw_stream_formation *formation) > { > unsigned int i, e, channels, type; > =20 > @@ -563,6 +566,10 @@ int snd_oxfw_stream_parse_format(const u8 *format, > if ((format[0] !=3D 0x90) || (format[1] !=3D 0x40)) > return -ENXIO; > =20 > + /* The entries should be within the response. */ > + if (len < 5 || len < 5 + format[4] * 2) > + return -EIO; > + > /* check the sampling rate */ > for (i =3D 0; i < ARRAY_SIZE(avc_stream_rate_table); i++) { > if (format[2] =3D=3D avc_stream_rate_table[i]) > @@ -624,6 +631,36 @@ int snd_oxfw_stream_parse_format(const u8 *format, > return 0; > } > =20 > +/* The cached formats were checked by check_and_parse_format(). */ > +int snd_oxfw_stream_parse_format(const u8 *format, > + struct snd_oxfw_stream_formation *formation) > +{ > + unsigned int i, e, channels, type; > + > + memset(formation, 0, sizeof(struct snd_oxfw_stream_formation)); > + > + for (i =3D 0; i < ARRAY_SIZE(avc_stream_rate_table); i++) { > + if (format[2] =3D=3D avc_stream_rate_table[i]) > + break; > + } > + if (i =3D=3D ARRAY_SIZE(avc_stream_rate_table)) > + return -ENXIO; > + > + formation->rate =3D oxfw_rate_table[i]; > + > + for (e =3D 0; e < format[4]; e++) { > + channels =3D format[5 + e * 2]; > + type =3D format[6 + e * 2]; > + > + if (type =3D=3D 0x00 || type =3D=3D 0x06) > + formation->pcm +=3D channels; > + else if (type =3D=3D 0x0d) > + formation->midi =3D channels; > + } > + > + return 0; > +} [Severity: Low] Does snd_oxfw_stream_parse_format() need to duplicate the memset(), avc_stream_rate_table lookup, and format[4] entry loop from check_and_parse_format()? Keeping two copies of the parser in the same file risks divergence between live and cached format parsing and adds churn to a stable-tagged fix. Instead, check_and_parse_format() could just validate format[0..1] and len, then delegate directly to the existing snd_oxfw_stream_parse_format(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261206-firewire-a= vc-bounds-v4-0-d90e91e0088e@gmail.com?part=3D3