From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 023A339FE1; Fri, 24 Nov 2023 18:00:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="BHoo6WD9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86243C433CA; Fri, 24 Nov 2023 18:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700848806; bh=+Dbz7XtCH9xV/z+fhDkYtRVJPtqaAQant25xsGmUYg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BHoo6WD91oWhzvpg2Kw42M3IrsSAgxm5ooc9C8Qk6l8jfYr1cCGw19I6HY+GhkwNe cstPLQMgFIpyM32MI6Lb4GImSExWo/yfRBJKW7/4mteVWbEutUsuo3M7HFSzjVe/VZ E/DnHI4uIptPQFV5Pacpcrp8Knsg9EiOuMSAETK4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nathan Hebert , Vikash Garodia , Stanimir Varbanov , Hans Verkuil Subject: [PATCH 4.19 87/97] media: venus: hfi: fix the check to handle session buffer requirement Date: Fri, 24 Nov 2023 17:51:00 +0000 Message-ID: <20231124171937.442712967@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231124171934.122298957@linuxfoundation.org> References: <20231124171934.122298957@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vikash Garodia commit b18e36dfd6c935da60a971310374f3dfec3c82e1 upstream. Buffer requirement, for different buffer type, comes from video firmware. While copying these requirements, there is an OOB possibility when the payload from firmware is more than expected size. Fix the check to avoid the OOB possibility. Cc: stable@vger.kernel.org Fixes: 09c2845e8fe4 ("[media] media: venus: hfi: add Host Firmware Interface (HFI)") Reviewed-by: Nathan Hebert Signed-off-by: Vikash Garodia Signed-off-by: Stanimir Varbanov Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/qcom/venus/hfi_msgs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/media/platform/qcom/venus/hfi_msgs.c +++ b/drivers/media/platform/qcom/venus/hfi_msgs.c @@ -359,7 +359,7 @@ session_get_prop_buf_req(struct hfi_msg_ memcpy(&bufreq[idx], buf_req, sizeof(*bufreq)); idx++; - if (idx > HFI_BUFFER_TYPE_MAX) + if (idx >= HFI_BUFFER_TYPE_MAX) return HFI_ERR_SESSION_INVALID_PARAMETER; req_bytes -= sizeof(struct hfi_buffer_requirements);