Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp915430rwb; Fri, 28 Jul 2023 01:35:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlGGOCEe8V6p9bwSCWlnqa2vjxY827Skdw3dW8x7YeSyi7GOE72o1jz0d+l9hjAyEYQLlA8Q X-Received: by 2002:a2e:9403:0:b0:2b5:7f93:b3b0 with SMTP id i3-20020a2e9403000000b002b57f93b3b0mr1018858ljh.17.1690533332242; Fri, 28 Jul 2023 01:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690533332; cv=none; d=google.com; s=arc-20160816; b=HVXHLITwigZND0+JDj3g2LCI01E1RjVsgrkkjvL8gVzX1K6y6oEkPp252ckC9GjvP1 LbsNl9fwORseFXYMEFq6NRyHdus1jtCMdRJLBTKJ4bcL8qJAzhwoq+7Wbn++oXupXHqU k/4PdKXA2gVhgB+T7Wgg/WGYs9UiwYz8k2KCzRbDlg5CtRKTJsi73S9zSLl7sOB64zIo Ucd3vAGk+7dkfHMMsc3XamJLa9ONrKsfI+Q5WxjSnKkqEoy5drZoUh9b9myYyn6jgtyY ilRXei/DS1DqUkhy0qJgHuChmbIAoeIp4d8EMDBKQYZuoYZzWTvv7kL+e0sQg5VOn+kU ZyCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=h8agajaLfWeXSOxgQ4Tqn5wqoCAvvaRjiSyfa4aGhpU=; fh=gLuL/7ZRVw39nWh6UUb5cWHEv57o1FG9L2K7ehsYOig=; b=lhvKeG1jp1629w53Ug5eSHfLCvFKdsr3MKqJokk0spAg3Lkdm5ylymmYY5a9hnauws 7Jdl3NCrlKP4aKRzR16VyxI4j+8vmS+2o2ZW5Rd2q7pHRHSbfxmK7Zdl/KLqNa+ebMes eP+YzLJEPMYhm/IYG+kLM+J6/RHHe6lobzHAY/tlbEX3dx2SnfNs892mdlwVM1SjErXr 2T9qnezBbAT3OdY75hXCGs4J9DWTdygHXa+0f/UqlxjpdjDwvUyBwgXZjLaF59OaeZex cZcYSit41NVMJCK3fESXKvAoS0+mjq/E24nlsBl9O31b+TdWbd5CVi46q55O/89ysrKS REEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=pVIwXsDa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a17090686cd00b00992ca642517si2389583ejy.104.2023.07.28.01.35.07; Fri, 28 Jul 2023 01:35:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=pVIwXsDa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234529AbjG1H52 (ORCPT + 99 others); Fri, 28 Jul 2023 03:57:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234526AbjG1H5W (ORCPT ); Fri, 28 Jul 2023 03:57:22 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB823582; Fri, 28 Jul 2023 00:57:20 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36S7c2g0020753; Fri, 28 Jul 2023 07:57:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=h8agajaLfWeXSOxgQ4Tqn5wqoCAvvaRjiSyfa4aGhpU=; b=pVIwXsDa7ajs3/hOdLSqOsyyBXKCem93pdxTki0S6PNOOGpGZBJYp0598QuF5AB1sxNx rUTA+7WPIWEDE9uKdTRSqzn8tDNWFDjDfWM1SV87KCLKWw6jtD0RGJBBsxOcDLFWOJk6 L07BDh75ELZwe+2ECA4gCbdSlZVOBQBm57hElFsS05zFxNczutvfUBSzxAcUX3Op1+v2 ca1/mQed0EgL/Jree3HuZFbemCYBck5uoJhtlRpIaf1mHH4bASG1hmteeVJICDWhkLRl LopOdqq7/QAqJr4/KBZAkpGr8kJWM07KX/XlRfcAYglbPLT+Ttg2KPT3U+oqLs3O8H7q bQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s3n2kapsp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jul 2023 07:57:13 +0000 Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36S7vCqY029525 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jul 2023 07:57:12 GMT Received: from [10.50.27.108] (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Fri, 28 Jul 2023 00:57:02 -0700 Message-ID: <6692f826-c2ca-3f8e-c6e5-d02a99150095@quicinc.com> Date: Fri, 28 Jul 2023 13:26:58 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 1/4] venus: hfi: add checks to perform sanity on queue pointers Content-Language: en-US To: Konrad Dybcio , , , , , , , CC: , , , References: <1690432469-14803-1-git-send-email-quic_vgarodia@quicinc.com> <1690432469-14803-2-git-send-email-quic_vgarodia@quicinc.com> From: Vikash Garodia In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: -6dzAtQqeXQpsT02Ey88kGVZfMtQ9ke- X-Proofpoint-ORIG-GUID: -6dzAtQqeXQpsT02Ey88kGVZfMtQ9ke- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_10,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 impostorscore=0 mlxscore=0 suspectscore=0 spamscore=0 clxscore=1015 bulkscore=0 mlxlogscore=825 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307280071 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/27/2023 10:38 PM, Konrad Dybcio wrote: > On 27.07.2023 06:34, Vikash Garodia wrote: >> Read and write pointers are used to track the packet index in the memory >> shared between video driver and firmware. There is a possibility of OOB >> access if the read or write pointer goes beyond the queue memory size. >> Add checks for the read and write pointer to avoid OOB access. >> >> Cc: stable@vger.kernel.org >> Fixes: d96d3f30c0f2 ("[media] media: venus: hfi: add Venus HFI files") >> Signed-off-by: Vikash Garodia >> --- >> drivers/media/platform/qcom/venus/hfi_venus.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c >> index f0b4638..dc228c4 100644 >> --- a/drivers/media/platform/qcom/venus/hfi_venus.c >> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c >> @@ -206,6 +206,10 @@ static int venus_write_queue(struct venus_hfi_device *hdev, >> >> new_wr_idx = wr_idx + dwords; >> wr_ptr = (u32 *)(queue->qmem.kva + (wr_idx << 2)); >> + >> + if (wr_ptr < (u32 *)queue->qmem.kva || wr_ptr > (u32 *)(queue->qmem.kva + queue->qmem.size)) > Shouldn't the cases on the right side of the OR operator include a > "- 1"? I see your point here. Possibly subtracting with sizeof(*wr_ptr) instead of "1" would be appropriate. Similarly for read queue handling. - Vikash > Konrad