From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796141983; b=LPUtdsB4/9NZIkwVuxdR/9OzRk/F4+gjtGqKftZbaO4yplit/d9RigLyFtAziSX15G0J +l7fiFJet77USHfYdiAxK3H8qGR4Coa+TQ5yX0ku06wfQIYouYjfiWlCewNe77KD94o4n O97EIMEJD71A1FWLxjNbo/1tgnT6Lk54gwVSPJZR3Nt7wuu4ynVnZJLHIvmEodonpo416 2avkksqiWz5hagW1n/X6hikqrJztvMcsuIrNJ2WzNvl0j0uXv1HycA8ASfF+V9k/cLj7L k66IyvlQYM0CmcE9wmM73SSoAunJfqRK2J3+uL66iI7+q8Qd9dYfgbFSW3i2gvPxAew== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796141983; h=DMARC-Filter:Received:DKIM-Signature:Message-ID:Subject:From:To:Cc: Date:In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version; bh=aF67dzuq0D6bB95bmWwoIyzn5YIhy9gE4zuP/CVOXnQ=; b=ZTF3hwYMHNRgI1pKGbkZEJb3hbnY0XB1G5sJ5roKil80+P+fFfjfj2ydPO8jNMEHyYui a2qBBobmB5lTcFIT8z53OglKL8trMQ5h/sLvvqrHqaWy1EykKRLqf6QHcnS6YP4pUDm0j 5ZhYqYjlhPmGBMm9McOEb67rkjfXSXkwBHvFkdO6QGYA6l2knmfk2q/cly3RseGozUSe9 n8+L/Ec/E/xNsg5nq4kLxvkHE9mK3m+DRM9SvWctBZ3obcoNfWp85MkNaooTnluWDmDt5 6WYh1e2y7FBFLSeHLvBjqa1IeQXbutZzMtx7cHxLzminuf9vJSJzOeaQYlGztbiRpxQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=Sv3iQv7G; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF87D60A2604; Tue, 1 Dec 2026 16:19:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EF87D60A2604 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=Sv3iQv7G Received: from [IPv6:2a0a:edc0:0:900:1d::4e] (lupine.office.stw.pengutronix.de [IPv6:2a0a:edc0:0:900:1d::4e]) (Authenticated sender: pza@pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id B6E05200883; Tue, 01 Dec 2026 17:19:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796141975; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aF67dzuq0D6bB95bmWwoIyzn5YIhy9gE4zuP/CVOXnQ=; b=Sv3iQv7G36kXlYTsg212gUvLPazis2hxoct+FlDdR2pVdFZcfea1xYLHUlHJoz7G85UxBP BU2EovcD4+aqQoDRNPzFLae4lNctR/UEunGEPq5e5bXy6/j6oyTHhdcZzUYUCvtd8C/1+8 yzwU4YixdMGSJVZtgCYfsW8SuJ6E5NDsKpqJ/5kwmJrS5pI087K32T35ERkLkBQUKAIEzm yUwpYB5u0H8f9ilz78SXV8N78U/jHLeFQNe0a+cqB2QJWNZBWmsAZ4tW+ZficdfQGyCvWA P5MgNMlx3Q+HINDPRB0aVfOIVe8LuImotK4HEObd1V4CdvJc1NrbEKz6bOO3vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796141975; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aF67dzuq0D6bB95bmWwoIyzn5YIhy9gE4zuP/CVOXnQ=; b=MfEKB2SF683v0nAtPyH3UcKtrDspP5RE8B6AituvPHfbCYBVg+tn9ywqWESsUWlcrXQ6mu O7fjrim27jGAhoqbm52o5vL24w85uPnXCkuD4i2yvBcJz7m7WUq8I+d4Y57J6sp0I7lUTe 0lViCmdtuFmjr2jbP3C7Y0+QMXvrsOW0BQwlihIztPw20uqnkCK3mcD0vI+GCIGwBAqe5o wtwV6n2fotZtIN2XTszL0Hk3hJezB7UR5gm9jKavp+wo9arV19WTwAFbi2ueeQYN1sfuhh kQwF5UiHlbiik3UZzwKR5dWYZf3ai05xfuLBBuMoUcU+t6HjqP5r0vg37/J1wA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pza@pengutronix.de smtp.mailfrom=p.zabel@pengutronix.de ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1796141975; a=rsa-sha256; cv=none; b=Gn4lsJNK11VzkxN0fuDy4PuJfAui4OBdyXDygksvHJ8YsEFK+yRYz7Ph0RhNwZq7ccrM0k hppCiGMcP3F8vNsG5UfxI0272e0bFjDJCm4fIu95jM1T5mm9ilkSe5TFkydJK9PYhypeSM ZeEZBcAwK48mx0D9bs/q+9LI5R5HgpHtmq2/k4iSB8FycGLSNya145G2keR4McD3Ojb9/u MB3k2m9ro5v7Ka7c8Vfukvzr0xcSHVkee242pqLHXaxZf5T5yMss7Q7qNFRaUwm1vUsecK d7+hsGwZd28srXS48egzKdjxoxZsmM0Ah1gg3Yv9U9kiLkkoWhkmCJs5WQcouw== Message-ID: Subject: Re: [PATCH] media: v4l2-jpeg: do not rewind the stream after Huffman tables From: Philipp Zabel To: aiyengar1990@gmail.com, Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 01 Dec 2026 17:19:35 +0100 In-Reply-To: <20261201-v4l2-jpeg-dht-rewind-v1-1-edf8b91a5c0f@gmail.com> References: <20261201-v4l2-jpeg-dht-rewind-v1-1-edf8b91a5c0f@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-0+deb13u1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Di, 2026-12-01 at 15:29 +0000, Arun Iyengar via B4 Relay wrote: > From: Arun Iyengar >=20 > After the table loop len is normally 0, so jpeg_skip(stream, len - 2) > moves the stream back two bytes and the next marker search rescans the > end of the last table. > > Return 0, as the quantization table parser does. I think the DQT parser is wrong. If there is remaining len, it should skip over it. > Fixes: 50733b5b9102 ("media: add v4l2 JPEG helpers") > Signed-off-by: Arun Iyengar > --- > Host test, parser built in userspace: a DHT ending in FF C4 gives -EINVAL > before and 0 after; a normal header parses the same. I expect you can trigger the same -EINVAL by adding a DHT segment header to the end of a DQT right now. > arm64 allmodconfig W=3D1 build is clean. Not run on coda hardware. >=20 > Developed with Claude (Anthropic) as a coding assistant, which wrote the > code and this message. I reviewed it. > --- > drivers/media/v4l2-core/v4l2-jpeg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/drivers/media/v4l2-core/v4l2-jpeg.c b/drivers/media/v4l2-cor= e/v4l2-jpeg.c > index 36a0f1a1b0d9..8b80f4b5311b 100644 > --- a/drivers/media/v4l2-core/v4l2-jpeg.c > +++ b/drivers/media/v4l2-core/v4l2-jpeg.c > @@ -525,7 +525,7 @@ static int jpeg_parse_huffman_tables(struct jpeg_stre= am *stream, > } > } > =20 > - return jpeg_skip(stream, len - 2); > + return 0; The error here is that this tries to subtract the two bytes for the segment length value again. Those were already subtracted at the start of the for loop. Wouldn't return jpeg_skip(stream, len); be correct? regards Philipp