dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sean Rhodes" <sean@starlabs.systems>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v13 RESEND 1/5] platform/x86: Sort firmware attributes class includes
Date: Mon, 24 Aug 2026 15:20:20 +0000	[thread overview]
Message-ID: <20260824152020.BAA4B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <b967ec0f8adb69417a3d81ee5546e4a238e29e11.1787584107.git.sean@starlabs.systems>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Out-of-bounds array read in get_instance_id macro due to an off-by-one error.
- [High] Out-of-bounds heap read and write in attribute_property_store macro via memchr.
--

--- Patch [1]: [PATCH v13 RESEND 1/5] platform/x86: Sort firmware attributes class includes ---
commit dff06344a1a1c35eb28b9e59670eeac00408066c
Author: Sean Rhodes <sean@starlabs.systems>

platform/x86: Sort firmware attributes class includes

Move firmware_attributes_class.h into the main include block and sort the
affected includes. This lets the header move replace each include in place.

> diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> index ab46a023cc34d..4ff9003c6589b 100644
> --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> @@ -8,18 +8,19 @@
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>  
>  #include <linux/align.h>
> -#include <linux/fs.h>
>  #include <linux/dmi.h>
> -#include <linux/module.h>
> +#include "../../firmware_attributes_class.h"
> +#include <linux/fs.h>
>  #include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/nls.h>
>  #include <linux/string.h>
>  #include <linux/sysfs.h>
>  #include <linux/wmi.h>
> +
>  #include "dell-wmi-sysman.h"

[Severity: High]
This is a pre-existing issue, but does the get_instance_id() macro in
dell-wmi-sysman.h have an off-by-one error in its loop condition?

drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h:get_instance_id() {
	...
	for (i = 0; i <= wmi_priv.type##_instances_count; i++) {
		if (!(strcmp(kobj->name, wmi_priv.type##_data[i].attribute_name)))
	...
}

If no match is found among the valid entries, the loop will evaluate 
i = instances_count and access wmi_priv.type##_data[i].attribute_name, which
is memory beyond the allocated array. The subsequent strcmp() function will
then dereference this out-of-bounds heap memory.

[Severity: High]
This is a pre-existing issue, but does the attribute_property_store() macro in 
dell-wmi-sysman.h have an out-of-bounds memory access?

drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h:attribute_property_store() {
	...
	buf_cp = kstrdup(buf, GFP_KERNEL);
	if (!buf_cp)
		return -ENOMEM;
	p = memchr(buf_cp, '\n', count);
	
	if (p != NULL)
		*p = '\0';
	...
}

kstrdup() determines the allocation size using strlen(buf). If a user
provides an input buffer with an embedded null byte before the newline
character, kstrdup() will allocate a buffer smaller than the user-provided
count.

Subsequently, memchr() searches for a newline character up to count bytes, 
reading beyond the dynamically allocated memory. Furthermore, if a newline 
character happens to be found in the out-of-bounds memory block, the code 
executes *p = '\0', causing an out-of-bounds heap write.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1787584107.git.sean@starlabs.systems?part=1

       reply	other threads:[~2026-08-24 15:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1787584107.git.sean@starlabs.systems>
     [not found] ` <b967ec0f8adb69417a3d81ee5546e4a238e29e11.1787584107.git.sean@starlabs.systems>
2026-08-24 15:20   ` sashiko-bot [this message]
2026-08-26  6:07   ` [PATCH v13 RESEND 1/5] platform/x86: Sort firmware attributes class includes Tzung-Bi Shih
     [not found] ` <557d363a779c3c03bfe939dc2fefd6a4265fa7ad.1787584107.git.sean@starlabs.systems>
2026-08-26  6:07   ` [PATCH v13 RESEND 3/5] firmware: Rename google firmware directory to coreboot Tzung-Bi Shih
2026-08-17 21:54 [PATCH v13 RESEND 0/5] coreboot CFR firmware attributes Sean Rhodes
2026-08-17 21:54 ` [PATCH v13 RESEND 1/5] platform/x86: Sort firmware attributes class includes Sean Rhodes

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=20260824152020.BAA4B1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sean@starlabs.systems \
    /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