From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 24820246790; Tue, 26 Aug 2025 13:21:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756214509; cv=none; b=nT9jtdM6l1k+rFX+sHnGpUuz30LnXh3IUiTXtbzyUyBaL/zgLlfXPiWbGyT9cASOH5V0KGT/2H90kZ6rJ/QAgt4lI0wv/TzzBLQ+xN+Zu96IcvDIxGOQyDhTuDPL395bLd6uDav15OV7JkqzPbh3Ke/s30lsG66A6QEBWZJpuCo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756214509; c=relaxed/simple; bh=jrOb9EL84Rdu8poYSbiTXF7SBv8adscDLRkIGCBMUI0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jYSThxr8QQe49hORzrtI61AZZ2TJSLEh4DV1qGItT0zuo+fAqHXcWh13Wr3D8lUOpnxSy1IINvbb1bt6i/B15sDxMk0pdiKd104uX/g9YUHxNgIoTMFmQRYfoAxlYwcWJQGlJIkOxCOrQVbJ4mEk2XI7r6H2C/R18/M/2daHkmE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ggc0x3uB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ggc0x3uB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD57EC4CEF1; Tue, 26 Aug 2025 13:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756214509; bh=jrOb9EL84Rdu8poYSbiTXF7SBv8adscDLRkIGCBMUI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ggc0x3uBc+LXurkoVMems2d6elpt0kno3YG71fpJyU5t45RcNO4OI7aDNzphf2W6I ecJ8Rl87P7YkzFtFEyLXqtb1VcC8m9JaK9RMrnep4sugt9DqnsMi8QmfgqrJ0829DB XgrI6nyGNOqhD7umLtaBWOUyMMWoD/3eVa6Q1QXg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hari Kalavakunta , Paul Fertser , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 165/482] net: ncsi: Fix buffer overflow in fetching version id Date: Tue, 26 Aug 2025 13:06:58 +0200 Message-ID: <20250826110934.887285389@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110930.769259449@linuxfoundation.org> References: <20250826110930.769259449@linuxfoundation.org> User-Agent: quilt/0.68 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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hari Kalavakunta [ Upstream commit 8e16170ae972c7fed132bc928914a2ffb94690fc ] In NC-SI spec v1.2 section 8.4.44.2, the firmware name doesn't need to be null terminated while its size occupies the full size of the field. Fix the buffer overflow issue by adding one additional byte for null terminator. Signed-off-by: Hari Kalavakunta Reviewed-by: Paul Fertser Link: https://patch.msgid.link/20250610193338.1368-1-kalavakunta.hari.prasad@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ncsi/internal.h | 2 +- net/ncsi/ncsi-rsp.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h index 2c260f33b55c..ad1f671ffc37 100644 --- a/net/ncsi/internal.h +++ b/net/ncsi/internal.h @@ -110,7 +110,7 @@ struct ncsi_channel_version { u8 update; /* NCSI version update */ char alpha1; /* NCSI version alpha1 */ char alpha2; /* NCSI version alpha2 */ - u8 fw_name[12]; /* Firmware name string */ + u8 fw_name[12 + 1]; /* Firmware name string */ u32 fw_version; /* Firmware version */ u16 pci_ids[4]; /* PCI identification */ u32 mf_id; /* Manufacture ID */ diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c index 8668888c5a2f..d5ed80731e89 100644 --- a/net/ncsi/ncsi-rsp.c +++ b/net/ncsi/ncsi-rsp.c @@ -775,6 +775,7 @@ static int ncsi_rsp_handler_gvi(struct ncsi_request *nr) ncv->alpha1 = rsp->alpha1; ncv->alpha2 = rsp->alpha2; memcpy(ncv->fw_name, rsp->fw_name, 12); + ncv->fw_name[12] = '\0'; ncv->fw_version = ntohl(rsp->fw_version); for (i = 0; i < ARRAY_SIZE(ncv->pci_ids); i++) ncv->pci_ids[i] = ntohs(rsp->pci_ids[i]); -- 2.39.5