From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 B88F130F7EE for ; Fri, 12 Dec 2025 08:10:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765527007; cv=none; b=OnTwFLplmVvItUAb52CEm9N5yO1Bx1PPGNigxPyxne3fn+pHKke25XCWFeglmIcaJO/qgK8HIsTNK/G4KXzdJVT67VlCHDzCAT1mvK5yyIMaYd0h9ONMHgTwXQAt/p44UYiCyIczXQvyrv7LIxmX/2R5sm7DZn1hpl0xXUWOQjg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765527007; c=relaxed/simple; bh=262qMIy8XJN9qZOWBSgU77Hp+N4Ybxy66X0+OIv83b0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=HozVAnWb3beEtKaftT3oqT1f8ak3SlHH8MYMEiTZvS2kZj8CmVSRQwqvruk8qcf63CzBi/0m96orc8JUP4Xd5AJ4tqePP7hZfnXrCH61uUVf5A4TCz0gZakMv1dGrnyqWHYchLTei3YGbqZ4cb9dj8cX0c2FxsVUWc9E2FoZOsQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QZ+5hVV7; arc=none smtp.client-ip=209.85.221.44 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.b="QZ+5hVV7" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-42fb3801f7eso216295f8f.3 for ; Fri, 12 Dec 2025 00:10:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765527004; x=1766131804; 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=fJ/CIq+S550sT8g8cfuPfmVxbEDEzZdlgJAf7FID7wY=; b=QZ+5hVV7lXV8OWt/rqUfe/EBbvCU3B+tJrxeuJsFvWD5qcwwenADk/o0prA65VYiMb S6EkcgCWrhnt3hBYCMbVjVGKfB6ah0ou9SA6V8weV9ua/oBBrQyF2bzudNHdnXeI53NO JByS2hBirW7GV+Dcn8Llyqfm74LLbMhOjI3UIkgyEO2q6rdg7LO3tjHm6yt7azdMIOSu AHJVm3EyMVVlBEn1el32AJJGbJMmo1x/FGXPrUFOKr9q5e9Tv0ovUt+trl7LI8nip3XF q8+mXkrKlRmvJaHMqiDwFwYyW9PJMXbVkTgsdcGK+oHUvsdgfmkM3YBBP8PVCjAO6Mnr e14Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765527004; x=1766131804; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fJ/CIq+S550sT8g8cfuPfmVxbEDEzZdlgJAf7FID7wY=; b=j1EdIOKa8TlZ4cBi/OVcc8F3tTX/CZ8jxFnVsCJlzFeoLhQh7XOtuBifggCKHA94QQ prVTQxfNEuusU3+2m1PaIAYQqVWp5T4lDeXw2RNNNMOOQ4RECfHo7wyJx4KJzKyVFjSs 1iuyE86fXxXFgqtlOBLUPXNAAA8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m/6LLYaeomx6J1Q== X-Received: by 2002:a05:6000:4012:b0:42b:2f79:755e with SMTP id ffacd0b85a97d-42fb44d46b4mr1032448f8f.3.1765527003664; Fri, 12 Dec 2025 00:10:03 -0800 (PST) Received: from ?IPV6:2003:df:bf2d:e300:84fc:a859:31e5:6980? (p200300dfbf2de30084fca85931e56980.dip0.t-ipconnect.de. [2003:df:bf2d:e300:84fc:a859:31e5:6980]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8b9b1f1sm10460373f8f.39.2025.12.12.00.10.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Dec 2025 00:10:03 -0800 (PST) Message-ID: <25aa90a7-e9f4-471e-9d93-c61b9a7a429c@gmail.com> Date: Fri, 12 Dec 2025 09:10:01 +0100 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 2/4] gpu: nova-core: gsp: Fix length of received messages To: Joel Fernandes , Alexandre Courbot Cc: Danilo Krummrich , Alice Ryhl , David Airlie , Simona Vetter , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , John Hubbard , Alistair Popple , Timur Tabi , Edwin Peer , "nouveau@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "rust-for-linux@vger.kernel.org" References: <20251122-nova-fixes-v1-0-a91eafeed7b5@nvidia.com> <20251122-nova-fixes-v1-2-a91eafeed7b5@nvidia.com> <504C636B-FB96-4B54-B9CD-C506026CCDB1@nvidia.com> Content-Language: de-AT-frami, en-US From: Dirk Behme In-Reply-To: <504C636B-FB96-4B54-B9CD-C506026CCDB1@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 12.12.25 08:59, Joel Fernandes wrote: > Hi Alex, > >> On Nov 22, 2025, at 12:00 AM, Alexandre Courbot wrote: >> >> The size of messages' payload is miscalculated, leading to extra data >> passed to the message handler. While this is not a problem with our >> current set of commands, others with a variable-length payload may >> misbehave. Fix this. >> >> Signed-off-by: Alexandre Courbot >> --- >> drivers/gpu/nova-core/gsp/cmdq.rs | 11 +++++++---- >> drivers/gpu/nova-core/gsp/fw.rs | 2 +- >> 2 files changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs >> index 6f946d14868a..dab73377c526 100644 >> --- a/drivers/gpu/nova-core/gsp/cmdq.rs >> +++ b/drivers/gpu/nova-core/gsp/cmdq.rs >> @@ -588,21 +588,24 @@ fn wait_for_msg(&self, timeout: Delta) -> Result> { >> header.length(), >> ); >> >> + // The length of the message that follows the header. >> + let msg_length = header.length() - size_of::(); > > Is this immune to under flow without one of the checked subtraction wrappers? Either way, we should not tolerate the underflow I think. Which means it can panic when the rust overflow checks are enabled. Since the header length comes from firmware, this cannot be guaranteed to not underflow in the event of a malformed message. Would this be a possible use case for the untrusted data proposal https://lwn.net/Articles/1034603/ ? Cheers Dirk