From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0553F40759D; Tue, 21 Jul 2026 15:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784648713; cv=none; b=sFbABQQUz2+7TTpqsU0EfjhlFSfhkSaMeVdSPPdtZwZog2eGM3zvmhnZf25cEXJ3rtUpvLvEn9n1DweSUTGFBkEwJZQhJPQyTU/1eaEyBjVbqllf1XtmrD/Yn+Cd8k50J6KTR6NxsWiz61P7GNVdbCdv8fO76ZpuwspVD14b46I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784648713; c=relaxed/simple; bh=WRE4CcNawixX7tEdPeRS2xct7BXboZR5aNg7VAx6Snw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u2R/2jBw136K9sjdRzL+eumvctX7cLP0tGlYQ7Q+DmropLrvbBnmUeSzdzAqZbyZ+5fBCHv0UwnUmysh0VqChiGslGk9ZvQjtj1shFZ0SO7LeVz/L+D7GlqsisRTZf931AkSX6T7wCNmi+PV/OCbXj0Il0lgtIRMpFCA54huLTM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xpObRpi8; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xpObRpi8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B8D61F000E9; Tue, 21 Jul 2026 15:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784648711; bh=VKCpPeOM1edqMsmotQbVQSnBR88kimXAN92GBqvRpUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xpObRpi8XUaPsj6qCyvsmFAe/zmOrreg05MtvBxfIm/uW1PcHOkm1fErUx0R0QA+Q cyPQ5gdD7NKyeKaPD6YfavEOk2W4btDDpUycMPG7QWgB1XT6zEUegau0+fGcrLyxTt Q7mkDXIVDI046X7KAb0QdqHRa+Wm/G8ZQnBVXt50= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joel Fernandes , John Hubbard , Eliot Courtney , Danilo Krummrich , Sasha Levin Subject: [PATCH 7.1 0302/2077] gpu: nova-core: vbios: use checked access in `FwSecBiosImage::header` Date: Tue, 21 Jul 2026 16:59:35 +0200 Message-ID: <20260721152559.802721606@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eliot Courtney [ Upstream commit 25ad950b4ee37f7b42e006f508a793b7c38fcc12 ] Use checked access in `FwSecBiosImage::header` for getting the header version since the value is firmware derived. Fixes: 47c4846e4319 ("gpu: nova-core: vbios: Add support for FWSEC ucode extraction") Reviewed-by: Joel Fernandes Reviewed-by: John Hubbard Signed-off-by: Eliot Courtney Link: https://patch.msgid.link/20260525-fix-vbios-v5-6-e5e455251537@nvidia.com Signed-off-by: Danilo Krummrich Signed-off-by: Sasha Levin --- drivers/gpu/nova-core/vbios.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs index 10f812714e4dcd..394877d5b2eae1 100644 --- a/drivers/gpu/nova-core/vbios.rs +++ b/drivers/gpu/nova-core/vbios.rs @@ -994,17 +994,14 @@ impl FwSecBiosBuilder { impl FwSecBiosImage { /// Get the FwSec header ([`FalconUCodeDesc`]). pub(crate) fn header(&self) -> Result { - // Get the falcon ucode offset that was found in setup_falcon_data. - let falcon_ucode_offset = self.falcon_ucode_offset; - - // Read the first 4 bytes to get the version. - let hdr_bytes: [u8; 4] = self.base.data[falcon_ucode_offset..falcon_ucode_offset + 4] - .try_into() - .map_err(|_| EINVAL)?; - let hdr = u32::from_le_bytes(hdr_bytes); - let ver = (hdr & 0xff00) >> 8; + let data = self + .base + .data + .get(self.falcon_ucode_offset..) + .ok_or(EINVAL)?; - let data = self.base.data.get(falcon_ucode_offset..).ok_or(EINVAL)?; + // Read the version byte from the header. + let ver = data.get(1).copied().ok_or(EINVAL)?; match ver { 2 => { let v2 = FalconUCodeDescV2::from_bytes_copy_prefix(data) -- 2.53.0