Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp175470rwb; Thu, 27 Jul 2023 11:00:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlHiaVhkBwVNfNiCmZ6xTgXxGyv4moM2vwkPaPaZvA/ZPD8xH1upEhEeFmOevMIsHQFGauQM X-Received: by 2002:a17:907:7856:b0:99b:ce19:ec1c with SMTP id lb22-20020a170907785600b0099bce19ec1cmr2450481ejc.73.1690480832237; Thu, 27 Jul 2023 11:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690480832; cv=none; d=google.com; s=arc-20160816; b=HgWTZCHpNEIvKhsPO+3R6Y4ERS+cKmsnGZtseBYsfdK3k/pSE81zhrezk0skXlyN73 2JRVdX4+ZrLrbzYPDucOaHvN2HCdQsvFV0otnwDSTD7tlN+qGUgaiSnbH6UFIT2RrvDx OIBlbcaq0O8Kbtcisz6Hm6IJ62Bng7610jDhVuP/UAJnbGeqVKTn+Yf/7wN382DCOihF ckv4hDeD4qYWakPWeKyKISaKQyecz9U8FiyOYRlFekKF1qvYp6TFkezgQHacthEj5pmq WMr9abbPhQ07Ta41kq4/tjVBrpfndaIcb415hFgJymQVBYUeQEaPa7lLdQsKKNIyAfK0 pYkQ== 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:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=YA4KY7APNBoaVIsE8pbZuVrmfLiy26uq1i7pnH5Zurc=; fh=o+a/HdGUJRAtQZLuq31MmS7qWd7z+zar0tX6jadH2B8=; b=AvuWVmwX+QFoG37GIsJnAIEGxk49YFDITJwB3Vyz47ZBvhde/yw2fUiqE7VVdlhhqF AwECWnKKuhxxAw543B8IT4TlbLKDdspoAtIGEyqjYIcNSzQGZRL+FU6WBW0JBEeMk23H 1bz/2Da6t53vPtgeGcd2QoP0e3yf5ugtiJfVGLb0ux7IDxhLAzp2/14AEf3q8StCO/Mq ht/pHmFj6SuX3rB13a+23JfxBzNt4H0c7XsC77vS/RupsH1/iVRA3IbYCFB23FtRvbWt U9QnH/Lir4fCkzC8yaMCe/+uubF4XUhX9GVEbbL0i/j28mypdvrSWOaSKigYtwkGCvug OIGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kU9RvC9M; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z14-20020a1709067e4e00b0096fe1a56de3si1227395ejr.1048.2023.07.27.11.00.07; Thu, 27 Jul 2023 11:00: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=@linaro.org header.s=google header.b=kU9RvC9M; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbjG0RKs (ORCPT + 99 others); Thu, 27 Jul 2023 13:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbjG0RKr (ORCPT ); Thu, 27 Jul 2023 13:10:47 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAC1C2D70 for ; Thu, 27 Jul 2023 10:10:44 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2b74209fb60so18545331fa.0 for ; Thu, 27 Jul 2023 10:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690477843; x=1691082643; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YA4KY7APNBoaVIsE8pbZuVrmfLiy26uq1i7pnH5Zurc=; b=kU9RvC9MMM1jkXnKHDH9Y7YHb/jOhWaYDV+48W6Vp1QVRVT5IN1Nbx2J3fu7lxkgxk bXHpKj/a9cTgAWSocNtrGS2015UQWdKNmAnaaCM/GNB/VTIoO3JnopGz/neyutp/SNz0 HttdyOVb9DnvYuA5Eq8kwtAIOnojFWbJJ7tp54kx35OUeLlv11MmbhtD/ZxW+/bGoC74 L2We5/1bmS4V2nVaCDcX+5n/T2En8pyA5sIpVNhcrv0qSRr+NoAHPI4qSjvDhXR+32B4 739OCJFYQ7fq8XXBViQNHYEI5IJZQUl2TUW+jXEWQ8Dbs1U5EDXB1ZDFrtoTOiNZlpN3 qMcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690477843; x=1691082643; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YA4KY7APNBoaVIsE8pbZuVrmfLiy26uq1i7pnH5Zurc=; b=Cjv5GuuT6huaj1885j/silMSXR7Kzyd+EnwFA5pNF1SOvKStft7uMoINfmpyXnzhEQ nbMAcdBZShkmDha27ohIU9auuhk4A4/pQc4bpQTMeEsjW+2iEhsl5shRZzfj9PzwAq3z rbt1W40Q60gO0C1OZ4s0uXrDQNr8e4OcNAccvGKA1tAQQG7hhiU9kzZGLoZ2LE/g3qEy 4+yL/7e50KTBLMTsHCT8Hm8lyfeKQARJqFeTORU/oJKSO2mpT+r5lahBvBpNBTREkSbD fHNx7P5iuciAR5nZ8iyqub4yLfRFjIR/p+IhBY9AoQFhmmzMiWoEUiGTpUdLOl9H8IGT kdzQ== X-Gm-Message-State: ABy/qLZlR/cFfaVHHkQWxVBgOFtLu6kYROZE/X69i+I6k8fV/zc0REnv E5PHxdAtDA5EK2JFKyOumZfNYA== X-Received: by 2002:a2e:3613:0:b0:2b6:dec9:2812 with SMTP id d19-20020a2e3613000000b002b6dec92812mr2191782lja.33.1690477842958; Thu, 27 Jul 2023 10:10:42 -0700 (PDT) Received: from [192.168.1.101] (abxi99.neoplus.adsl.tpnet.pl. [83.9.2.99]) by smtp.gmail.com with ESMTPSA id y4-20020a2eb004000000b002b944151da5sm441863ljk.81.2023.07.27.10.08.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Jul 2023 10:09:12 -0700 (PDT) Message-ID: Date: Thu, 27 Jul 2023 19:08:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/4] venus: hfi: add checks to perform sanity on queue pointers Content-Language: en-US To: Vikash Garodia , stanimir.k.varbanov@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, mchehab@kernel.org, hans.verkuil@cisco.com, tfiga@chromium.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <1690432469-14803-1-git-send-email-quic_vgarodia@quicinc.com> <1690432469-14803-2-git-send-email-quic_vgarodia@quicinc.com> From: Konrad Dybcio Autocrypt: addr=konrad.dybcio@linaro.org; keydata= xsFNBF9ALYUBEADWAhxdTBWrwAgDQQzc1O/bJ5O7b6cXYxwbBd9xKP7MICh5YA0DcCjJSOum BB/OmIWU6X+LZW6P88ZmHe+KeyABLMP5s1tJNK1j4ntT7mECcWZDzafPWF4F6m4WJOG27kTJ HGWdmtO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H7N8Bs9jy0wQYezNzqS+FxoNXmDQg2jetX8en4bO2Di7Pmx0jXA4TOb9TM izWDgYvmBE8= In-Reply-To: <1690432469-14803-2-git-send-email-quic_vgarodia@quicinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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"? Konrad