mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Saket Dumbre <saket.dumbre@intel.com>,
	Ahmed Salem <x0rw3ll@gmail.com>,
	Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Subject: [PATCH v1] ACPICA: Switch back to using strncpy() in acpi_ut_safe_strncpy()
Date: Thu, 29 May 2025 17:43:13 +0200	[thread overview]
Message-ID: <12685690.O9o76ZdvQC@rjwysocki.net> (raw)

From: Ahmed Salem <x0rw3ll@gmail.com>

ACPICA commit b90d0d65ec97ff8279ad826f4102e0d31c5f662a

I mistakenly replaced strncpy() with memcpy() in commit ebf27765421c
("ACPICA: Replace strncpy() with memcpy()"), not realizing the entire
context behind *why* strncpy() was used.

In this safer implementation of strncpy(), it does not make
sense to use memcpy() only to null-terminate strings passed to
acpi_ut_safe_strncpy() one byte early.

The consequences of doing so are understandably *bad*, as was
evident by the kernel test bot reporting problems [1].

Fixes: ebf27765421c ("ACPICA: Replace strncpy() with memcpy()")
Link: https://lore.kernel.org/all/202505081033.50e45ff4-lkp@intel.com [1]
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202505081033.50e45ff4-lkp@intel.com
Link: https://github.com/acpica/acpica/commit/b90d0d65
Signed-off-by: Ahmed Salem <x0rw3ll@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 utnonansi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -Nurp linux.before_name/drivers/acpi/acpica/utnonansi.c linux.after_name/drivers/acpi/acpica/utnonansi.c
--- linux.before_name/drivers/acpi/acpica/utnonansi.c	2025-05-29 17:24:27.130073452 +0200
+++ linux.after_name/drivers/acpi/acpica/utnonansi.c	2025-05-29 17:24:22.076757944 +0200
@@ -168,7 +168,7 @@ void acpi_ut_safe_strncpy(char *dest, ch
 {
 	/* Always terminate destination string */
 
-	memcpy(dest, source, dest_size);
+	strncpy(dest, source, dest_size);
 	dest[dest_size - 1] = 0;
 }
 




                 reply	other threads:[~2025-05-29 15:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=12685690.O9o76ZdvQC@rjwysocki.net \
    --to=rjw@rjwysocki.net \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikhail.v.gavrilov@gmail.com \
    --cc=saket.dumbre@intel.com \
    --cc=x0rw3ll@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®