From: Greg KH <gregkh@linuxfoundation.org>
To: Sebastian Josue Alba Vives <sebasjosue84@gmail.com>
Cc: marvin24@gmx.de, ac100@lists.launchpad.net,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] staging: nvec: validate battery response length before memcpy
Date: Mon, 30 Mar 2026 07:49:33 +0200 [thread overview]
Message-ID: <2026033007-echo-preschool-36a4@gregkh> (raw)
In-Reply-To: <20260329210800.597697-1-sebasjosue84@gmail.com>
On Sun, Mar 29, 2026 at 03:08:00PM -0600, Sebastian Josue Alba Vives wrote:
> From: Sebastián Alba Vives <sebasjosue84@gmail.com>
>
> In nvec_power_notifier(), the response length from the embedded
> controller is used directly as the size argument to memcpy() when
> copying battery manufacturer, model, and type strings. The
> destination buffers (bat_manu, bat_model, bat_type) are fixed at
> 30 bytes, but res->length is a u8 that can be up to 255, allowing
> a heap buffer overflow.
>
> Additionally, if res->length is less than 2, the subtraction
> res->length - 2 wraps around as an unsigned value, resulting in a
> large copy that corrupts kernel heap memory.
>
> Introduce NVEC_BAT_STRING_SIZE to replace the hardcoded buffer
> size, store res->length - 2 in a local copy_len variable for
> clarity, and add bounds checks before each memcpy to ensure the
> copy length does not exceed the destination buffer and that
> res->length is at least 2 to prevent unsigned integer underflow.
>
> Tested-by: Marc Dietrich <marvin24@gmx.de>
> Cc: stable@vger.kernel.org
> Signed-off-by: Sebastián Alba Vives <sebasjosue84@gmail.com>
> ---
> v2:
> - Introduce NVEC_BAT_STRING_SIZE constant to replace hardcoded
> buffer size (Marc Dietrich)
> - Store res->length - 2 in local copy_len variable for clarity
> (Marc Dietrich)
> - Use NVEC_BAT_STRING_SIZE in strncmp call for consistency
> drivers/staging/nvec/nvec_power.c | 41 +++++++++++++++++++++----------
> 1 file changed, 28 insertions(+), 13 deletions(-)
Is there a reason you are not sending these to the staging maintainer
and mailing list so that they can actually be applied?
thanks,
greg k-h
next prev parent reply other threads:[~2026-03-30 5:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-29 21:08 [PATCH v2] staging: nvec: validate battery response length before memcpy Sebastian Josue Alba Vives
2026-03-30 5:49 ` Greg KH [this message]
2026-03-30 9:36 ` kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2026-03-30 6:09 Sebastian Josue Alba Vives
2026-03-30 23:05 ` kernel test robot
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=2026033007-echo-preschool-36a4@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=ac100@lists.launchpad.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=marvin24@gmx.de \
--cc=sebasjosue84@gmail.com \
--cc=stable@vger.kernel.org \
/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 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.