From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.229.135 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796158624; b=bMqhXiJ32GfV5tFbsq5Szbrmj1AXNJyYBCsHcQFuBuvB/3uP+jksnzH7CiTtxh5LUV/S dlgLG/GU3gILHmXdZF9rAyC8hySuGZmCl511SDI6FJCwxeKGRQU9BvLvCAGHwHPp90TLd /PiyZrHMcI7oKxGBAitgj8Zz5dSDMAgoLxdTIBYMiRXApsOPWVoj9dM0lGZE5/0RNfXx4 onLAx6m/pm4Saxn30kmQ1pnwS1UbJKKcDU2qcN8t+SUO+YD1+I+BaJ8xVlup7S8gkzpGv XGJdWhPuMplk+/LTTDiOyFWDugJTjFKT6kH6rkyIhwDIuM9CACz+L7UIQiwV9JK1p1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796158624; 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=yj+FoiIJvfRAPJ9B/b+Ai/31jwfuYpb5sVYg50kg2tw=; b=2hZ5z5mYIJwEbdBpmcYkvBK/d6qVTw3qhhzNsjPouNFbDzHuC0kfxP+EvgFmhPx4tYq9 5Qc/vQcVFMCRvy5xd45lnHGNteQhxL9hb2M3p64WOvGplvC1zEza7dmRFthSxUiFO3cOo 6utnOgl7/rUMDUFJBm/eJa8kypBhxxI76NK2ktxwrfo/9EMZKcUYcJan/SwRqtWMK4TYr 9nNrX4mc8MXcWA7aWcSzYidRON+HMLxsnjnKis/ExVFMkLwaAAuolpQGkR3USbR+Zqx6Q 7iAU+xiHe1PU7ZTgvdWQvAf2vE+TFc6bK2cGMx/FaldGbASUKODxdPzRzjFa2sSoFrA== 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=WeNEWCyq; arc=none smtp.remote-ip=74.125.229.135 Received: from mail-dl2-f7.google.com (mail-dl2-f7.google.com [74.125.229.135]) (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 8BC99606A682 for ; Tue, 1 Dec 2026 20:57:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8BC99606A682 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=WeNEWCyq Received: by mail-dl2-f7.google.com with SMTP id a92af1059eb24-13985f8229aso10056352c88.1 for ; Tue, 01 Dec 2026 12:57:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796158624; x=1796763424; 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=yj+FoiIJvfRAPJ9B/b+Ai/31jwfuYpb5sVYg50kg2tw=; b=WeNEWCyqR4fBbvWyhRhcIW14m+Ej9ZyQIoqkm0b02+LNhnpnZZ5cc4vSaPYYdDgvm+ sXO1x/cTkGLbDcMo6gJR3sqj2G1IORx3+sBriw95Mh0kRfE/MLJ+8p6Jt6kinTVFKl8d O8vyR5vm065ieegJMH/NE8bNdDf7BVjCkQqKSZixCV3cPFocrStjBvzv3kVwKEFSgEHG nJFNy/zWcLAKjD/wm3Lg3eM92XW3tUbRsEpuqj3ujuYn71E3z0D+B/GpHDnPi28HW2M2 C3xKJoTgTp0g+rIal0zys0ZZxHopmJ+4jcbU42QaOP950x6OEi+9jKYmIzye+nK2wZJw HjpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796158624; x=1796763424; 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=yj+FoiIJvfRAPJ9B/b+Ai/31jwfuYpb5sVYg50kg2tw=; b=rqmvmmjoHnhtP+rFiKkfNHoQBKZKqCkRl5tnQJzIRh87wWlnCOPZWtZ8udFlFDfFvZ p473i9A2eknF4NjHRU+LrMTaCuNRyc+W1nvpwHvaYWJRLGgU/lC8yNOv1VNw2ULKoaP2 ZzhPPBj60+vRmtNQ83xY/N+KZzjE/aHg2wN0iAsng92UopU2nQNSuIYFpNw9Xh1dE6QS JEk/31C4kuYYm3O+96NXtJeydnXIioI04EH7rZ4aC2ZV8kDkIcEGEzFe5h8GhwvRGQ8h INm/+nweSEenD4qfUqq1GPNFgM+lY7z+/E2ZcwkP8A2uTT9kDqwHfnpSOWo3ndXInRb8 sGoQ== X-Forwarded-Encrypted: i=1; AL+hErEnb5zKDmRbBu8OkBqw1jKmof1sGlqIIdlGkocZLt3uv0c4mlfLYkGohPdanw0JTm01VFRi4EBLDKwrsP8=@vger.kernel.org X-Gm-Message-State: APuU4Z/GK4zQXPbLawd0PmlpMpsnZeW+jXe8SLHkxz0dDXgKbS73xboh 87EbNYE/oLitLttzn08I75xU5GHgq5VhhAdRWy0FsNoaV8zhTbNMKFwY X-Gm-Gg: AZFdTZdqv3H1s/YY0+tilyxy2ZW82i0okjvHizSJUlpnIlSmRrDEUTroMjkOa7vGx3f dyfFiPtO9GeRZ+y6s8vLOqqcAmxRrwgJk4T2Wh35jSBA67XkFgGrVL5M+bwsJLwCaPcIWyJ6odR X5ETCn0HIZsFKJlygId4ldEHzVFN16mH76LLxuthJWtFW44qlREKPpjJgb3rrd6c1UyhCVqElXc GmW53mdAXU2LaF/GVxxBC9kyPPT+95Ljnu1hTNyQXp5AIjbRJfyzOS/8EFYH/aXbcH15p2GPufl jWnlxiTbMTNxuhE+QmW2b1d1hFEkwVBkn1eqnJC6/qfxC8/DbacNoBJzIz3uLimjOYLPMl6CIVI DoVnYer3xSLadO7gwFGJRvVxjs33LKnCaTLObNvBaNshtoLXUCJRsH35X0vT2PDIMB86YY57CK7 RTp2EyCZAtsD3HC5i2fiSKDilM+Br38/k+0HSX+luFq5LrFHMtA4fuiMGmxewRA8GdCZpnf13Dw 4Wn2g7I5DeW7tOZfqlz5sUze3y/9Rz1YT1qiKZONiAM7PmfVKMNXqHNJzeidYUjqEnA3PXkNDKD RrkQ69K09DOH1Lz1dPJi79QvatWrrQjRIzf3L9DHR291IBVF4awBCbeP8pryaRdx/TkcKIxop5j ELwKxzQX4QpCC9YvN8aGOE03dbJpmwmO6hyJKVHv53w== X-Received: by 2002:a05:7022:3f0d:b0:1b5:3aca:8116 with SMTP id a92af1059eb24-1b55690bcfemr35420101c88.33.1796158623553; Tue, 01 Dec 2026 12:57:03 -0800 (PST) Received: from localhost.localdomain ([76.33.234.50]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5567ff27bsm103208079c88.6.2026.12.01.12.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 12:57:03 -0800 (PST) From: Hungyu Lin To: vikash.garodia@oss.qualcomm.com, dikshita.agarwal@oss.qualcomm.com Cc: abhinav.kumar@linux.dev, bod@kernel.org, konrad.dybcio@oss.qualcomm.com, mchehab@kernel.org, hverkuil@kernel.org, stefan.schmidt@linaro.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dennylin0707@gmail.com, Bryan O'Donoghue Subject: [PATCH v3 2/3] media: iris: check the packet size after reading from shared memory Date: Tue, 1 Dec 2026 20:56:41 +0000 Message-ID: <20261201205642.32436-3-dennylin0707@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261201205642.32436-1-dennylin0707@gmail.com> References: <20261201205642.32436-1-dennylin0707@gmail.com> 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 Content-Transfer-Encoding: 8bit iris_hfi_queue_read() takes the size of a packet from the first word of the packet in the shared queue and then copies that many bytes, including that word, out of the queue. The firmware can change the word in between, so the size field of the copy can be larger than what was copied. The gen1 response handlers use that field as the length of the packet, for example to walk the buffer requirements in iris_hfi_gen1_session_property_info(). venus got the same check in commit 49befc830daa ("media: venus: Add a check for packet size after reading from shared memory"). Compare the size field of the copy with the size that was used for the copy and fail the read if they differ. Fixes: fb583a214337 ("media: iris: introduce host firmware interface with necessary hooks") Cc: stable@vger.kernel.org Signed-off-by: Hungyu Lin Reviewed-by: Bryan O'Donoghue --- drivers/media/platform/qcom/iris/iris_hfi_queue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_queue.c b/drivers/media/platform/qcom/iris/iris_hfi_queue.c index 12a7fd0982c5..55711f332a50 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_queue.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_queue.c @@ -95,6 +95,8 @@ static int iris_hfi_queue_read(struct iris_iface_q_info *qinfo, void *packet) qinfo->kernel_vaddr, residue); new_read_idx = residue; } + if (*(u32 *)packet != packet_size) + return -EINVAL; } else { new_read_idx = write_idx; ret = -EBADMSG; -- 2.43.0