mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: "Stuart Hayes" <stuart.w.hayes@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Andrew Morton" <akpm@osdl.org>,
	"Doug Warzecha" <Douglas_Warzecha@dell.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 4/4] platform/x86: dell: dcdbas: Validate the WSMT buffer description
Date: Mon, 16 Nov 2026 12:40:52 -0800	[thread overview]
Message-ID: <aa437d954b48790ef8a3d770c2ec4207aec4d8f7.1794861287.git.rosenp@gmail.com> (raw)
In-Reply-To: <cover.1794861287.git.rosenp@gmail.com>

dcdbas_check_wsmt() takes the address and size of the firmware SMI
buffer from an SMBIOS OEM string or from an EPS table in the BIOS area,
and sets

	smi_buf.size = remap_size - 8;
	max_smi_data_buf_size = smi_buf.size;

without checking that remap_size covers the 8 byte semaphore. An OEM
string such as "30[addr;4]" would make the size wrap to almost 2^64,
and smi_data reads and writes could then access memory well past the
mapping.

check_eps_table() also accepts a table with length 0, since the
checksum of zero bytes is zero, and then trusts the rest of it.

No firmware is known to describe the buffer like this, so this is
hardening against malformed tables rather than a fix for a reported
problem. Reject buffers smaller than the semaphore, and EPS tables
shorter than struct smm_eps_table.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/platform/x86/dell/dcdbas.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/dell/dcdbas.c b/drivers/platform/x86/dell/dcdbas.c
index 0db278eed5d8..1e854f02e171 100644
--- a/drivers/platform/x86/dell/dcdbas.c
+++ b/drivers/platform/x86/dell/dcdbas.c
@@ -538,6 +538,9 @@ static inline struct smm_eps_table *check_eps_table(u8 *addr)
 	if (strncmp(eps->smm_comm_buff_anchor, SMM_EPS_SIG, 4) != 0)
 		return NULL;
 
+	if (eps->length < sizeof(*eps))
+		return NULL;
+
 	if (checksum(addr, eps->length) != 0)
 		return NULL;
 
@@ -598,6 +601,12 @@ static int dcdbas_check_wsmt(void)
 		dev_warn(&dcdbas_pdev->dev, "found WSMT, but buffer address is above 4GB\n");
 		return -EINVAL;
 	}
+	/* The first 8 bytes are a semaphore, not part of the data buffer */
+	if (remap_size < 8) {
+		dev_warn(&dcdbas_pdev->dev, "found WSMT, but buffer size %llu is too small\n",
+			 remap_size);
+		return -EINVAL;
+	}
 	/*
 	 * Limit remap size to MAX_SMI_DATA_BUF_SIZE + 8 (since the first 8
 	 * bytes are used for a semaphore, not the data buffer itself).
-- 
2.56.1


      parent reply	other threads:[~2026-11-16 20:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 20:40 [PATCH v2 0/4] platform/x86: dell: dcdbas: Fix SMI completion wait and buffer handling Rosen Penev
2026-11-16 20:40 ` [PATCH v2 1/4] platform/x86: dell: dcdbas: Actually wait for the host control SMI Rosen Penev
2026-11-16 20:40 ` [PATCH v2 2/4] platform/x86: dell: dcdbas: Suppress bind attributes of the platform driver Rosen Penev
2026-11-16 20:40 ` [PATCH v2 3/4] platform/x86: dell: dcdbas: Release the SMI buffer in remove Rosen Penev
2026-11-16 20:40 ` Rosen Penev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aa437d954b48790ef8a3d770c2ec4207aec4d8f7.1794861287.git.rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=Douglas_Warzecha@dell.com \
    --cc=akpm@osdl.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=stuart.w.hayes@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®