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=1796158625; b=iUU/KuqEGYAzscqa3LzhR2DS+HwjYC6Dq8wJyPkPXa8Sjd8jvIAYuTwGChzW9P0s11eX YeTvrztCNpIDNK4YKCcOYzloVDxcL1SYFP8CXEhydV2P6MAjK3ybJkuu9KOW5rmXt/4eA G4fJLk5CTwhwhGU5H2WxlKXm52nmimrA/EKCDYP6L1Q80k0kxxMmo5yeXGXwrSKgYnl0A sZLlbo+BVYYM2f9y0f0r2TEPxn2wxC7zdeMY3wPN9OHqRCvna+ZJB11cAgo9b3kGVlvaM uJo6mxnWS+ivcMEDESib1oImeGGacltqxvnQtuQv4MYybLq1xTa6GUPXpO0iUMHqY3A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796158625; 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=m4qrYAlPHBjgrVpfx1PNJa99vk8U0gB8oqWDl66NMEYt3AcJOWE6L7PiM5zaGjs4GYdf fSq+zkw2BlSyZiFVh3FzCc6ZCvAFF1HOhHFZxBPrfJaDJP/6hI1IuikkeViYc7No4Znt3 NkVf+aH4ANu/Dl9/21f1MBSooI9ml4LVh10Nu5Jb68aUv9kWXDHLMzZ35Co0r4H/7i+8v U1bdxJ7WRy/SYunO2uN2AJcYYNtf4eMsS5lmzHPF7L+gXvXnhjR1UoRrtVFDSOnEk3Fle 8MAm0vXxmOKcZnfyGi05BQrnvybT50p/b9CPFIW4xOrNESpQuwEjqUEwtg4pW8Ln3ow== 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 8BCD2606A683 for ; Tue, 1 Dec 2026 20:57:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8BCD2606A683 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-13985f8229aso10056347c88.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=RCWS+8Ts/2crEvgsVebM951RLwLVudtdLEOBZH6exjX4CUDvhSa5F7a0SJx0XQF7U6 k7Qvhxdu3oh19bJPhbf59zWt9fcyOCnu4l9ohpfH4Q3Kq+Rjw5bM4EwTykt496DYH47I 19ZI7WIZwEfPRecvZ8on4N4RyQlSKHV27km47IWz+pPOGUMiB7ajQFydUUVf6495jCi0 q6N0fDTFymuD1WRwuy2uWLsCrVzAWnrQNAvBOrcTfuaoLVYzIHBpzAbD0nCGdU5Zw63h +Jg3rPLbSWi90amiLj8ntnchK5UbzYHtgQ/sgqSfCMmjsR7tAJQcdri8wCfENlexLpbZ K2vw== X-Forwarded-Encrypted: i=1; AL+hErGY+b2vMi13+5yNdF988zBGyZgEJG2cEcAywjS7lISRuWj0ipCaMmXf2+a2mbfhj2hikytMIxJi2JhbvlOH@vger.kernel.org X-Gm-Message-State: APuU4Z/8JGZKSW9UHOvvHj/Jh3GhFIGl7z26LalCoSHWuyS9tsJbTd7U d7/cXfFiqrzFT3YeZUIsHLFtn7D43WspNPse45cnsSN8py1i8p4GeFC0 X-Gm-Gg: AZFdTZd5v15CetBV5yTVMvH4F5bedDqWIDSUI/Zvd09Q4CM96bbcahTlF7TF2SsZnhq jCgbw5RndCRl7C6mhjnR/BDzsMW/d04Tjw/76Pi5sND5n0yZ5hInQFCeq4K0a+AALKsSW42D/He 367dQ4AUy86AvrJKUTCdDYxnbJhCfSZv7ovC6uddo8ElDPBWw4LTxOn6Ab0MNx82b31cCQDRKwx CJYMXaNB2FcPPqT12sJWidAWOX3iW1mQy9RwUca8qAgJf9+3fQIo+x/aa8HcoJBV82N4+dYrGGS k7ww+HHIjH/vb4ANkUS72FzPICLwP4cBSpgcaoIuRMd57Bc/OP88N63UkCnW0NveqVsL7Wi6PPg y8DBf8XeTxZXJX/poi9hSylwgRWlWa+RqUuGE1LWrK8p0lFEB857O5XuncrdPhCeMChjx6rOBpk +Mv5Zaqmnjb/m6ksgVqG6oVH3imkq2evg0Tyk0bUeRD5zc/F6luOUMED0wyvbFquzT9vbYPhEkb 4t/mCAfZQJ8Tvukf+AEPqG6q/3rtisSpv2rOD14r9deaSpunq7gTBxqAbH2BU1tJ8gZSVSlvtWO JSk/+PUuhuZlXmfp5zWWsZkbIWPQ4beM/PKoanrdNAvO0noAdadQLVDAUIKVgMn2z+xNSHRzn5S Zo4UtbUFHDVqNf8kI6i8qpqx2Nx93fz5hf6GXdXzsgg== 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-arm-msm@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