From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4FF31FC0F5 for ; Fri, 17 Jan 2025 10:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737109523; cv=none; b=N7Os0cekQm6SA4/5KISfFssc9cEKR+GxQX/r9riNp+wIANMMSgraH0ephKrW5az1WSWGxQb+pnJgKJUGvrQEOFJETp4dslEfz8AgaeSOLE3vHJCh3+9+sB2i2Xotmb1+PLwgLCrmFydv91DthCTGLHTBfIHyEO2sxWXVwCq5JO0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737109523; c=relaxed/simple; bh=q/nN/WiCZeyxTX8vPRtvY+0LU60DeiKLc5hOr1qUdFg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JlIvfSUrrRacKNu2MDbW44/VsJHxMHcT7yVjQna/p+fOEi1LKc461Fkh8F1+Zlb0nOfMMwJ4LCFyUUwuSWHaB+UCglDsTNwSsQmD5JnZ/moekQK7a7F6Q/mr2tTiYDB8SX+jEoWbmIIzSodzi4BC6EKqe93O/l+qPp2LRRDEYsw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=xjkQqZwu; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xjkQqZwu" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4361815b96cso12232325e9.1 for ; Fri, 17 Jan 2025 02:25:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737109520; x=1737714320; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=AuyZog7HTl0jURH59KuN4aP3Mv7PVs0SAeDjI1tKXiA=; b=xjkQqZwuW+5djwjo5/P1a/wlQG87HRFtgs6PUAJySqXcLkfXibIw8VDZb9Gh8imZaj /PxCf/ddvJ5qaeWuFzvBKUHRS9Rf2gbwvosjK/con73fHpOo9jl/tYvYfJaU3Dj6wN1s HHEeTtlt5XxI2WMVroZ2FLJK4lhYEG+q61u8831CLjdak5yMsSzIShOKEQQxWckRIwZz gWNAJSjLaS2Qo5PpHpdhbSVPEyLqAgBDfHHX/9zlfQ+wzhSGrvW+H7XiFcuslVMqT/Ip TB7c6CZlH181b2bNmB4IMSPGBLt0fvmPL4sd2h7IIg2H2UMna8PFCL9Ncv0imric4xDf Z8EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737109520; x=1737714320; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AuyZog7HTl0jURH59KuN4aP3Mv7PVs0SAeDjI1tKXiA=; b=HvWgD/o2SFj+TGql8ooqD0d8sgFK6eroltBvIZmiaGB8vu/wwLop4ZrqP6uNhxg5D+ 4Ri1Ncgh8kdc+QFir0Txmn798ewHJyh/KysIwh7UTe69E2FLCCFKcOCLfGwDUQBJy04U 6M/K8++ASKPq0BVORfRB8ukI0g+xQRusPTJpD8fkEQyzOz7TCKAiby1LdSRRwwcieLWV mTMXvaaJtvC+AkJOeOkNV2J2TRRysO3C1ehumN9Ijp/1DDtU1QhQH4KSJxI8Q4dwppsP ncHF20JbJepOIaeS6DrMpv+Z6OMftuVhn/OTYVDQqjvdLbq+Q3z4WBBRYc2Xlaaeb4QQ tCew== X-Forwarded-Encrypted: i=1; AJvYcCWSFb2JjV7FHOHll2giXLx/SFcrXS0N0WL68vCCcvt6Ka5Z3YacO2EjpjpCy08cq1rkW213pKNCuhj3oX4=@vger.kernel.org X-Gm-Message-State: AOJu0Yxx5twszitwkGNaUdQnpdMEWFxU/cHw70s2c9kuXJ0avuZubhpD CZRXaqfO+T6CUILbCnc3gC80l5L7B/WIMaEVJxkQDuO6NBN4ouVEl9BVMa/0Nb4= X-Gm-Gg: ASbGncsYOh6PE0io7aLAzXpW6DSsstiVQYm8f6ArlMOB0IzzBR4e+s3YeGyhtocuqiW vtzaUp9sz08KJGvJN3JDzN2gz9icdQTbwPrYeBe7hEiWj7O6xhSkN9ame+Co0wxyCh96Ts7q/sZ l+uQ+Km259LBm2O6qZ5n95R2Nleqt5E8PlyEzyYXCQrjh804gkyyve6u5OKNNiXfaROf89lN7wJ FjtFqzCMRHPEVM21xWIZ3qWUiXPvRMgf2Jkq69i+C+wiN4xBVnLgz8/6X5NGWC6AWn2HQ== X-Google-Smtp-Source: AGHT+IFMdHIo3hLDXgRf7TiH8FxEI+sqFiJFDa4eqUh4eXr2VBNPBxbAhK8vVgaHtALTy3+mKyBL3A== X-Received: by 2002:a05:600c:3149:b0:434:f270:a513 with SMTP id 5b1f17b1804b1-4389144e70fmr19855415e9.29.1737109520209; Fri, 17 Jan 2025 02:25:20 -0800 (PST) Received: from [192.168.0.35] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43890408a66sm29182285e9.5.2025.01.17.02.25.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jan 2025 02:25:19 -0800 (PST) Message-ID: <4cfc1fe1-2fab-4256-9ce2-b4a0aad1069e@linaro.org> Date: Fri, 17 Jan 2025 10:25:18 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] media: venus: fix OOB read issue due to double read To: Vedang Nagar , Stanimir Varbanov , Vikash Garodia , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250104-venus-security-fixes-v1-0-9d0dd4594cb4@quicinc.com> <20250104-venus-security-fixes-v1-1-9d0dd4594cb4@quicinc.com> <13259345-02b0-47ff-94a8-530a17c50b97@quicinc.com> Content-Language: en-US From: Bryan O'Donoghue In-Reply-To: <13259345-02b0-47ff-94a8-530a17c50b97@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 17/01/2025 08:39, Vedang Nagar wrote: > Below is the first read where dwords is being validated properly with the checks. > dwords = *rd_ptr >> 2; > > Whereas the same address is being read for the second time: > memcpy(pkt, rd_ptr, dwords << 2); > > For the second read the value is not validated which may get updated from the firmware > leading to incorrect memcpy into the packet and may lead to OOB read access while accessing > the packet. So you are saying that pkt points to memory that the firmware and host can simultaneously access. The question is - if the length value can change between one read and another read - how do you trust the _content_ of the packet ? Surely the right thing to do is to take a _copy_ of the entire frame and act on that frame exclusively on the host side ? If I receive a frame, and read length X. Then I need to re-read that frame because length may now by X+3. This implies the _data_ in the frame has changed. What exactly is the valid lifetime of this data from HFI RX interrupt ? --- bod