From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 76AAF606A33E for ; Tue, 1 Dec 2026 12:45:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=V6Zc+TSG; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AHX/PGYF DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=owQhpduaVZp7G1YRzN+ge8Kzkf1uYNZp5Wf8ryHyYjY=; b=V6Zc+TSGQcErxL b/6vZ9aG7J0jCt2sdJqWoxMAx0ogFN4s5oXKFHepM3N9cMMtsiSPNPx5bWoIrJ+9kmAOczPto9Qhj jnnZH+SJotwaK+1LY3YktG1An2ErNxVUYXlCC9otiafcJ8nl1UnGfD5+DvSTzE0WYFFi7UBCcP+nV Dk1IRtEpUNGqQzsYiqk/4VZnQkxnLrlNpaNDqL4PM+IxF0W5idIJPUj2y4aGz1bMsALG4HL4EZHfO gRL+vmOG1/QbTUu8i85d+8f+/ezAT0zsCeGQf2KKTh70R4iPAh+4p4/M94uGeE39gNskEV6Vq9krl 9Sidth0L+tALZKBBcjPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYN76-00000007nRn-0Ir5; Tue, 01 Dec 2026 12:37:40 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYN72-00000007nRQ-44xF for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 12:37:39 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 4639C407E8; Tue, 1 Dec 2026 12:37:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FE7F1F000C1; Tue, 1 Dec 2026 12:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796128656; bh=owQhpduaVZp7G1YRzN+ge8Kzkf1uYNZp5Wf8ryHyYjY=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=AHX/PGYFtgS8GGSM11paNo5jNIn2hSjtCFRmD6lywvUOfPwuR8aBHknVBIBj01sFU PdN6ujpiyxoGXkb2tdEUNykKI7YThLa4ZtNccXlwfSsQw69gyZ0tSAFEuzp6gW+W0r iLpxi144VHEIMlvAhs7gvhZvc72cP8yxR+giU2xOwX42Vo2ZL6wKhDYAEMU4wqXklK 7Ily+6IXN8IeEsIZBqi4h+pJAYkerkv22m4KDIGUu3JNnLFYh7rV2J5IHXP1Jw6HRG VITih3KlmIpI1pIizHSDdw0mrYOkG2PRfvPBXN1Tmhy8x0AQ2qPUHosak8zsC6S/bz 6XqJgHXe8isoQ== Message-ID: <22c24d86-6909-432d-af8c-8fe7a5c10b60@kernel.org> Date: Tue, 1 Dec 2026 13:37:32 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] media: exynos4-is: fimc: Fix reading uninitialized plane sizes To: Lin Huiyi , s.nawrocki@samsung.com Cc: mchehab@kernel.org, krzk@kernel.org, peter.griffin@linaro.org, alim.akhtar@samsung.com, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org References: From: Hans Verkuil Content-Language: en-US, nl In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 29/11/2026 17:54, Lin Huiyi wrote: > fimc_get_sensor_frame_desc() pre-fills the media bus frame descriptor > entries from plane_fmt[].sizeimage before invoking the sensor subdev > operation. The only call site that sets the frame description > (__video_try_or_set_format(), try=true) passes a properly initialized > array, but fimc_pipeline_validate() passes a plain uninitialized stack > array and only wants to query the sensor with get_frame_desc(). The > pre-fill thus reads uninitialized stack memory and passes it to the > sensor driver. > > Only fill the descriptor entries when the caller is going to set the > frame description. > > Signed-off-by: Lin Huiyi > --- > .../media/platform/samsung/exynos4-is/fimc-capture.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-capture.c b/drivers/media/platform/samsung/exynos4-is/fimc-capture.c > index 8d7e7b1905..ecfff86f9c 100644 > --- a/drivers/media/platform/samsung/exynos4-is/fimc-capture.c > +++ b/drivers/media/platform/samsung/exynos4-is/fimc-capture.c > @@ -858,8 +858,14 @@ static int fimc_get_sensor_frame_desc(struct v4l2_subdev *sensor, > int i, ret; > int pad; > > - for (i = 0; i < num_planes; i++) > - fd.entry[i].length = plane_fmt[i].sizeimage; > + /* > + * Pre-fill the frame descriptor with the caller provided plane > + * sizes. Callers which only query the sensor pass an uninitialized > + * array here, so only do this when setting the frame description. > + */ > + if (try) > + for (i = 0; i < num_planes; i++) > + fd.entry[i].length = plane_fmt[i].sizeimage; > > pad = sensor->entity.num_pads - 1; > if (try) I'm not sure this code is right, and it may have been wrong in the first place. It calls set_frame_desc if try == true, but when called from fimc_cap_s_fmt_mplane() the 'try' argument is false, and in that case fimc_get_sensor_frame_desc actually calls get_frame_desc. That doesn't feel right. I wonder if anyone from Samsung has a board to test with, since I think the current code is just wrong. Not helped by poor naming. I think that: 1) Make a fimc_set_sensor_frame_desc function that calls set_frame_desc, and the existing fimc_get_sensor_frame_desc just calls get_frame_desc. Both functions can drop the 'bool try'. For the 'set' variant initialize fd.entry[i].length as per your current patch. 2) Call the correct function elsewhere in the code. Regards, Hans