* [PATCH v2 1/3] Doc: deprecated.rst: add strlcat()
2026-05-14 16:07 [PATCH v2 0/3] Doc, scripts: facilitate phaseout of strlcat Manuel Ebner
@ 2026-05-14 16:26 ` Manuel Ebner
2026-05-14 16:31 ` Kees Cook
2026-05-14 16:28 ` [PATCH v2 2/3] scripts: checkpatch.pl: add warning for strlcat() Manuel Ebner
2026-05-14 16:30 ` [PATCH v2 3/3] drivers: add deprecated remarks to strlcat() Manuel Ebner
2 siblings, 1 reply; 7+ messages in thread
From: Manuel Ebner @ 2026-05-14 16:26 UTC (permalink / raw)
To: Andy Shevchenko, Kees Cook, Jonathan Corbet, Shuah Khan,
Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn,
Geert Uytterhoeven, David Laight, Randy Dunlap, Jani Nikula,
Heiko Carstens, open list:DOCUMENTATION PROCESS,
open list:DOCUMENTATION, open list
Cc: Manuel Ebner
add strlcat and alternatives
Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
---
Documentation/process/deprecated.rst | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
index fed56864d036..06e802f4bbfd 100644
--- a/Documentation/process/deprecated.rst
+++ b/Documentation/process/deprecated.rst
@@ -153,6 +153,13 @@ used, and the destinations should be marked with the `__nonstring
attribute to avoid future compiler warnings. For cases still needing
NUL-padding, strtomem_pad() can be used.
+strlcat()
+---------
+strlcat() must re-scan the destination string from the beginning on each
+call (O(n^2) behavior). Alternatives are seq_buf_puts() and seq_buf_printf().
+snprintf(), scnprintf() and sysfs_emit() are possible aswell, but the adoption
+of the arguments needs to be taken care off.
+
strlcpy()
---------
strlcpy() reads the entire source buffer first (since the return value
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] Doc: deprecated.rst: add strlcat()
2026-05-14 16:26 ` [PATCH v2 1/3] Doc: deprecated.rst: add strlcat() Manuel Ebner
@ 2026-05-14 16:31 ` Kees Cook
2026-05-14 17:51 ` Randy Dunlap
0 siblings, 1 reply; 7+ messages in thread
From: Kees Cook @ 2026-05-14 16:31 UTC (permalink / raw)
To: Manuel Ebner
Cc: Andy Shevchenko, Jonathan Corbet, Shuah Khan, Andy Whitcroft,
Joe Perches, Dwaipayan Ray, Lukas Bulwahn, Geert Uytterhoeven,
David Laight, Randy Dunlap, Jani Nikula, Heiko Carstens,
open list:DOCUMENTATION PROCESS, open list:DOCUMENTATION,
open list
On Thu, May 14, 2026 at 06:26:53PM +0200, Manuel Ebner wrote:
> add strlcat and alternatives
>
> Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
> ---
> Documentation/process/deprecated.rst | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
> index fed56864d036..06e802f4bbfd 100644
> --- a/Documentation/process/deprecated.rst
> +++ b/Documentation/process/deprecated.rst
> @@ -153,6 +153,13 @@ used, and the destinations should be marked with the `__nonstring
> attribute to avoid future compiler warnings. For cases still needing
> NUL-padding, strtomem_pad() can be used.
>
> +strlcat()
> +---------
> +strlcat() must re-scan the destination string from the beginning on each
> +call (O(n^2) behavior). Alternatives are seq_buf_puts() and seq_buf_printf().
> +snprintf(), scnprintf() and sysfs_emit() are possible aswell, but the adoption
> +of the arguments needs to be taken care off.
> +
How about just:
strlcat() must re-scan the destination string from the beginning on each
call (O(n^2) behavior). Use the seq_buf API or similar instead.
> strlcpy()
> ---------
> strlcpy() reads the entire source buffer first (since the return value
> --
> 2.54.0
>
--
Kees Cook
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] Doc: deprecated.rst: add strlcat()
2026-05-14 16:31 ` Kees Cook
@ 2026-05-14 17:51 ` Randy Dunlap
0 siblings, 0 replies; 7+ messages in thread
From: Randy Dunlap @ 2026-05-14 17:51 UTC (permalink / raw)
To: Kees Cook, Manuel Ebner
Cc: Andy Shevchenko, Jonathan Corbet, Shuah Khan, Andy Whitcroft,
Joe Perches, Dwaipayan Ray, Lukas Bulwahn, Geert Uytterhoeven,
David Laight, Jani Nikula, Heiko Carstens,
open list:DOCUMENTATION PROCESS, open list:DOCUMENTATION,
open list
On 5/14/26 9:31 AM, Kees Cook wrote:
> On Thu, May 14, 2026 at 06:26:53PM +0200, Manuel Ebner wrote:
>> add strlcat and alternatives
>>
>> Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
>> ---
>> Documentation/process/deprecated.rst | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
>> index fed56864d036..06e802f4bbfd 100644
>> --- a/Documentation/process/deprecated.rst
>> +++ b/Documentation/process/deprecated.rst
>> @@ -153,6 +153,13 @@ used, and the destinations should be marked with the `__nonstring
>> attribute to avoid future compiler warnings. For cases still needing
>> NUL-padding, strtomem_pad() can be used.
>>
>> +strlcat()
>> +---------
>> +strlcat() must re-scan the destination string from the beginning on each
>> +call (O(n^2) behavior). Alternatives are seq_buf_puts() and seq_buf_printf().
>> +snprintf(), scnprintf() and sysfs_emit() are possible aswell, but the adoption
>> +of the arguments needs to be taken care off.
>> +
>
> How about just:
>
> strlcat() must re-scan the destination string from the beginning on each
> call (O(n^2) behavior). Use the seq_buf API or similar instead.
>
Yeah, that avoids the "aswell" (should be "as well").
>
>> strlcpy()
>> ---------
>> strlcpy() reads the entire source buffer first (since the return value
>> --
>> 2.54.0
>>
>
--
~Randy
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] scripts: checkpatch.pl: add warning for strlcat()
2026-05-14 16:07 [PATCH v2 0/3] Doc, scripts: facilitate phaseout of strlcat Manuel Ebner
2026-05-14 16:26 ` [PATCH v2 1/3] Doc: deprecated.rst: add strlcat() Manuel Ebner
@ 2026-05-14 16:28 ` Manuel Ebner
2026-05-14 16:32 ` Kees Cook
2026-05-14 16:30 ` [PATCH v2 3/3] drivers: add deprecated remarks to strlcat() Manuel Ebner
2 siblings, 1 reply; 7+ messages in thread
From: Manuel Ebner @ 2026-05-14 16:28 UTC (permalink / raw)
To: Andy Shevchenko, Kees Cook, Jonathan Corbet, Shuah Khan,
Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn,
Geert Uytterhoeven, David Laight, Randy Dunlap, Jani Nikula,
Heiko Carstens, open list:DOCUMENTATION PROCESS,
open list:DOCUMENTATION, open list
Cc: Manuel Ebner
add a warning for strlcat()
Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 0492d6afc9a1..4c1b43ebe00d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7085,6 +7085,12 @@ sub process {
"Prefer strscpy over strlcpy - see: https://github.com/KSPP/linux/issues/89\n" . $herecurr);
}
+# strlcat uses that should be a more supported function
+ if ($line =~ /\bstrlcat\s*\(/ && !is_userspace($realfile)) {
+ WARN("STRLCAT",
+ "Prefer a more supported function over strlcat - see: https://github.com/KSPP/linux/issues/370\n" . $herecurr);
+ }
+
# strncpy uses that should likely be strscpy or strscpy_pad
if ($line =~ /\bstrncpy\s*\(/ && !is_userspace($realfile)) {
WARN("STRNCPY",
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2 2/3] scripts: checkpatch.pl: add warning for strlcat()
2026-05-14 16:28 ` [PATCH v2 2/3] scripts: checkpatch.pl: add warning for strlcat() Manuel Ebner
@ 2026-05-14 16:32 ` Kees Cook
0 siblings, 0 replies; 7+ messages in thread
From: Kees Cook @ 2026-05-14 16:32 UTC (permalink / raw)
To: Manuel Ebner
Cc: Andy Shevchenko, Jonathan Corbet, Shuah Khan, Andy Whitcroft,
Joe Perches, Dwaipayan Ray, Lukas Bulwahn, Geert Uytterhoeven,
David Laight, Randy Dunlap, Jani Nikula, Heiko Carstens,
open list:DOCUMENTATION PROCESS, open list:DOCUMENTATION,
open list
On Thu, May 14, 2026 at 06:28:59PM +0200, Manuel Ebner wrote:
> add a warning for strlcat()
>
> Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] drivers: add deprecated remarks to strlcat()
2026-05-14 16:07 [PATCH v2 0/3] Doc, scripts: facilitate phaseout of strlcat Manuel Ebner
2026-05-14 16:26 ` [PATCH v2 1/3] Doc: deprecated.rst: add strlcat() Manuel Ebner
2026-05-14 16:28 ` [PATCH v2 2/3] scripts: checkpatch.pl: add warning for strlcat() Manuel Ebner
@ 2026-05-14 16:30 ` Manuel Ebner
2 siblings, 0 replies; 7+ messages in thread
From: Manuel Ebner @ 2026-05-14 16:30 UTC (permalink / raw)
To: Andy Shevchenko, Kees Cook, Jonathan Corbet, Shuah Khan,
Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn,
Geert Uytterhoeven, David Laight, Randy Dunlap, Jani Nikula,
Heiko Carstens, open list:DOCUMENTATION PROCESS,
open list:DOCUMENTATION, open list
Cc: Manuel Ebner
add kernel-doc comment to strlcat() function definitions
Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
---
lib/string.c | 11 +++++++++++
tools/include/nolibc/string.h | 11 +++++++++++
2 files changed, 22 insertions(+)
diff --git a/lib/string.c b/lib/string.c
index b632c71df1a5..0a44ca5ca7e6 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -249,6 +249,17 @@ EXPORT_SYMBOL(strncat);
#endif
#ifndef __HAVE_ARCH_STRLCAT
+/**
+ * strlcat - Append a string to an existing string
+ *
+ * @dest: pointer to %NUL-terminated string to append to
+ * @src: pointer to %NUL-terminated string to append from
+ * @count: Maximum bytes available in @dest
+ *
+ * Do not use this function. Prefer building the string with
+ * formatting, via scnprintf(), seq_buf, or similar.
+ *
+ */
size_t strlcat(char *dest, const char *src, size_t count)
{
size_t dsize = strlen(dest);
diff --git a/tools/include/nolibc/string.h b/tools/include/nolibc/string.h
index 4000926f44ac..1a4b51135705 100644
--- a/tools/include/nolibc/string.h
+++ b/tools/include/nolibc/string.h
@@ -208,6 +208,17 @@ char *strndup(const char *str, size_t maxlen)
}
static __attribute__((unused))
+/**
+ * strlcat - Append a string to an existing string
+ *
+ * @dst: pointer to %NUL-terminated string to append to
+ * @src: pointer to %NUL-terminated string to append from
+ * @size: Maximum bytes available in @dst
+ *
+ * Do not use this function. Prefer building the string with
+ * formatting, via scnprintf(), seq_buf, or similar.
+ *
+ */
size_t strlcat(char *dst, const char *src, size_t size)
{
size_t len = strnlen(dst, size);
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread