* [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad()
@ 2026-06-22 18:23 Rafael J. Wysocki
2026-06-23 4:02 ` Jiri Slaby
2026-06-23 19:28 ` Kees Cook
0 siblings, 2 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-06-22 18:23 UTC (permalink / raw)
To: Linux ACPI
Cc: Thomas Renninger, Jiri Slaby, LKML, Saket Dumbre, Kees Cook,
Chmielewski, Pawel
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Commit 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in
acpi_ut_safe_strncpy()") switched over the ACPICA code in the kernel to
using strscpy_pad() instead of a combination of strncpy() and manual
NUL-termination of the destination string, but it overlooked the fact
that tools also use the code in question and strscpy_pad() is not
defined in those builds.
Address that by using the original ACPICA code in non-kernel builds.
Fixes: 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in acpi_ut_safe_strncpy()")
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Closes: https://lore.kernel.org/all/79e9e913-0fb1-4110-804b-c3b5d0edafe4@kernel
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpica/utnonansi.c | 10 ++++++++++
1 file changed, 9 insertions(+)
--- a/drivers/acpi/acpica/utnonansi.c
+++ b/drivers/acpi/acpica/utnonansi.c
@@ -168,7 +168,17 @@ void acpi_ut_safe_strncpy(char *dest, ch
{
/* Always terminate destination string */
+#ifdef __KERNEL__
strscpy_pad(dest, source, dest_size);
+#else
+ /*
+ * strscpy_pad() is not defined in ACPICA tools builds, so use strncpy()
+ * and directly NUL-terminate the destination string in that case.
+ */
+ strncpy(dest, source, dest_size);
+ dest[dest_size - 1] = 0;
+#endif
}
#endif
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad()
2026-06-22 18:23 [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad() Rafael J. Wysocki
@ 2026-06-23 4:02 ` Jiri Slaby
2026-06-23 10:49 ` Rafael J. Wysocki
2026-06-23 19:28 ` Kees Cook
1 sibling, 1 reply; 4+ messages in thread
From: Jiri Slaby @ 2026-06-23 4:02 UTC (permalink / raw)
To: Rafael J. Wysocki, Linux ACPI
Cc: Thomas Renninger, LKML, Saket Dumbre, Kees Cook,
Chmielewski, Pawel
On 22. 06. 26, 20:23, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Commit 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in
> acpi_ut_safe_strncpy()") switched over the ACPICA code in the kernel to
> using strscpy_pad() instead of a combination of strncpy() and manual
> NUL-termination of the destination string, but it overlooked the fact
> that tools also use the code in question and strscpy_pad() is not
> defined in those builds.
>
> Address that by using the original ACPICA code in non-kernel builds.
>
> Fixes: 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in acpi_ut_safe_strncpy()")
> Reported-by: Jiri Slaby <jirislaby@kernel.org>
> Closes: https://lore.kernel.org/all/79e9e913-0fb1-4110-804b-c3b5d0edafe4@kernel
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/acpi/acpica/utnonansi.c | 10 ++++++++++
> 1 file changed, 9 insertions(+)
>
> --- a/drivers/acpi/acpica/utnonansi.c
> +++ b/drivers/acpi/acpica/utnonansi.c
> @@ -168,7 +168,17 @@ void acpi_ut_safe_strncpy(char *dest, ch
Hmm, how could this become 17, provided you are adding 9 lines to 7
lines? Fixed to 16 and applied -- testing.
> {
> /* Always terminate destination string */
>
> +#ifdef __KERNEL__
> strscpy_pad(dest, source, dest_size);
> +#else
> + /*
> + * strscpy_pad() is not defined in ACPICA tools builds, so use strncpy()
> + * and directly NUL-terminate the destination string in that case.
> + */
> + strncpy(dest, source, dest_size);
> + dest[dest_size - 1] = 0;
> +#endif
> }
>
> #endif
>
>
>
--
js
suse labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad()
2026-06-23 4:02 ` Jiri Slaby
@ 2026-06-23 10:49 ` Rafael J. Wysocki
0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-06-23 10:49 UTC (permalink / raw)
To: Jiri Slaby
Cc: Rafael J. Wysocki, Linux ACPI, Thomas Renninger, LKML,
Saket Dumbre, Kees Cook, Chmielewski, Pawel
On Tue, Jun 23, 2026 at 6:02 AM Jiri Slaby <jirislaby@kernel.org> wrote:
>
> On 22. 06. 26, 20:23, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > Commit 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in
> > acpi_ut_safe_strncpy()") switched over the ACPICA code in the kernel to
> > using strscpy_pad() instead of a combination of strncpy() and manual
> > NUL-termination of the destination string, but it overlooked the fact
> > that tools also use the code in question and strscpy_pad() is not
> > defined in those builds.
> >
> > Address that by using the original ACPICA code in non-kernel builds.
> >
> > Fixes: 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in acpi_ut_safe_strncpy()")
> > Reported-by: Jiri Slaby <jirislaby@kernel.org>
> > Closes: https://lore.kernel.org/all/79e9e913-0fb1-4110-804b-c3b5d0edafe4@kernel
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> > drivers/acpi/acpica/utnonansi.c | 10 ++++++++++
> > 1 file changed, 9 insertions(+)
> >
> > --- a/drivers/acpi/acpica/utnonansi.c
> > +++ b/drivers/acpi/acpica/utnonansi.c
> > @@ -168,7 +168,17 @@ void acpi_ut_safe_strncpy(char *dest, ch
>
> Hmm, how could this become 17, provided you are adding 9 lines to 7
> lines? Fixed to 16 and applied -- testing.
Yeah, I manually updated the comment and forgot to refresh the patch
afterward. Sorry.
> > {
> > /* Always terminate destination string */
> >
> > +#ifdef __KERNEL__
> > strscpy_pad(dest, source, dest_size);
> > +#else
> > + /*
> > + * strscpy_pad() is not defined in ACPICA tools builds, so use strncpy()
> > + * and directly NUL-terminate the destination string in that case.
> > + */
> > + strncpy(dest, source, dest_size);
> > + dest[dest_size - 1] = 0;
> > +#endif
> > }
> >
> > #endif
> >
> >
> >
>
>
> --
> js
> suse labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad()
2026-06-22 18:23 [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad() Rafael J. Wysocki
2026-06-23 4:02 ` Jiri Slaby
@ 2026-06-23 19:28 ` Kees Cook
1 sibling, 0 replies; 4+ messages in thread
From: Kees Cook @ 2026-06-23 19:28 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, Thomas Renninger, Jiri Slaby, LKML, Saket Dumbre,
Chmielewski, Pawel
On Mon, Jun 22, 2026 at 08:23:09PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Commit 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in
> acpi_ut_safe_strncpy()") switched over the ACPICA code in the kernel to
> using strscpy_pad() instead of a combination of strncpy() and manual
> NUL-termination of the destination string, but it overlooked the fact
> that tools also use the code in question and strscpy_pad() is not
> defined in those builds.
Eek. Thanks for fixing this! (This looks almost exactly like the shared
BPF header solution: non-kernel build just keeps using strncpy.)
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-23 19:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22 18:23 [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad() Rafael J. Wysocki
2026-06-23 4:02 ` Jiri Slaby
2026-06-23 10:49 ` Rafael J. Wysocki
2026-06-23 19:28 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox