mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Zaid Alali <zaidal@os.amperecomputing.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	"Len Brown" <lenb@kernel.org>,
	"James Morse" <james.morse@arm.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Ira Weiny" <ira.weiny@intel.com>,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Al Viro" <viro@zeniv.linux.org.uk>,
	"Sudeep Holla" <sudeep.holla@arm.com>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH next] ACPI: APEI: EINJ: prevent memory corruption in error_type_set()
Date: Wed, 25 Jun 2025 18:58:50 +0300	[thread overview]
Message-ID: <738b8abd-5825-48cf-9c5c-697ae057ab79@suswa.mountain> (raw)
In-Reply-To: <4d800ffb-fb1a-464d-adcc-2802187cfa9a@sabinyo.mountain>

On Wed, Jun 25, 2025 at 10:23:26AM -0500, Dan Carpenter wrote:
> The "einj_buf" buffer is 32 chars.  Verify that "count" is not too large
> for that.  Also leave the last character as a NUL terminator to ensure
> the string is properly terminated.
> 
> Fixes: 0c6176e1e186 ("ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/acpi/apei/einj-core.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index d6d7e36e3647..e77c0d4b4ee5 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
> @@ -826,8 +826,11 @@ static ssize_t error_type_set(struct file *file, const char __user *buf,
>  	int rc;
>  	u64 val;
>  
> +	if (count > sizeof(einj_buf))
> +		return -EINVAL;
> +
>  	memset(einj_buf, 0, sizeof(einj_buf));
> -	if (copy_from_user(einj_buf, buf, count))
> +	if (copy_from_user(einj_buf, buf, min(count, sizeof((einj_buf) - 1))))

Nope.  I put the parentheses in the wrong place...  Let me resend.

regards,
dan carpenter

  reply	other threads:[~2025-06-25 15:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 15:23 Dan Carpenter
2025-06-25 15:58 ` Dan Carpenter [this message]
2025-06-25 18:57 Dan Carpenter
2025-06-25 21:21 ` Ira Weiny
2025-06-26 18:47   ` Rafael J. Wysocki

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=738b8abd-5825-48cf-9c5c-697ae057ab79@suswa.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bp@alien8.de \
    --cc=ira.weiny@intel.com \
    --cc=james.morse@arm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=tony.luck@intel.com \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zaidal@os.amperecomputing.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®