All of
 help / color / mirror / Atom feed
From: Kees Cook <>
To: Hans de Goede <>
Cc: "Kees Cook" <>,
	"Mark Gross" <>,
	"Mario Limonciello" <>,
	"Pali Rohár" <>,
	"Andy Shevchenko" <>,
	"Uwe Kleine-König" <>,,,
	"Andy Lavr" <>,,
Subject: [PATCH][RFC] platform/x86: dell-smbios-wmi: Avoid false-positive memcpy() warning
Date: Wed, 25 Aug 2021 09:07:49 -0700	[thread overview]
Message-ID: <> (raw)

In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memcpy(), memmove(), and memset(), avoid
intentionally writing across neighboring fields.

Since all the size checking has already happened, use input.pointer
(void *) so memcpy() doesn't get confused about how much is being

Avoids this false-positive warning when run-time memcpy() strict
bounds checking is enabled:

memcpy: detected field-spanning write (size 4096) of single field (size 36)
WARNING: CPU: 0 PID: 357 at drivers/platform/x86/dell/dell-smbios-wmi.c:74 run_smbios_call+0x110/0x1e0 [dell_smbios]

Note: is there a missed kfree() in the marked error path?

Cc: Hans de Goede <>
Cc: Mark Gross <>
Cc: Mario Limonciello <>
Cc: "Pali Rohár" <>
Cc: Andy Shevchenko <>
Cc: "Uwe Kleine-König" <>
Reported-by: Andy Lavr <>
Signed-off-by: Kees Cook <>
 drivers/platform/x86/dell/dell-smbios-wmi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/dell/dell-smbios-wmi.c b/drivers/platform/x86/dell/dell-smbios-wmi.c
index 33f823772733..c410d6d920b8 100644
--- a/drivers/platform/x86/dell/dell-smbios-wmi.c
+++ b/drivers/platform/x86/dell/dell-smbios-wmi.c
@@ -69,9 +69,10 @@ static int run_smbios_call(struct wmi_device *wdev)
 		if (obj->type == ACPI_TYPE_INTEGER)
 			dev_dbg(&wdev->dev, "SMBIOS call failed: %llu\n",
+		/* output.pointer memory allocation leak? */
 		return -EIO;
-	memcpy(&priv->buf->std, obj->buffer.pointer, obj->buffer.length);
+	memcpy(input.pointer, obj->buffer.pointer, obj->buffer.length);
 	dev_dbg(&wdev->dev, "result: [%08x,%08x,%08x,%08x]\n",
 		priv->buf->std.output[0], priv->buf->std.output[1],
 		priv->buf->std.output[2], priv->buf->std.output[3]);

             reply	other threads:[~2021-08-25 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 16:07 Kees Cook [this message]
2021-08-25 16:32 ` [PATCH][RFC] platform/x86: dell-smbios-wmi: Avoid false-positive memcpy() warning Andy Shevchenko
2021-08-26 13:57 ` Hans de Goede

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:

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

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \

* 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.