]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.6-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Jul 2026 11:08:08 +0000 (13:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Jul 2026 11:08:08 +0000 (13:08 +0200)
added patches:
selftests-bpf-add-simple-strscpy-implementation.patch
tools-testing-add-linux-args.h-header-and-fix-radix-vma-tests.patch

queue-6.6/selftests-bpf-add-simple-strscpy-implementation.patch [new file with mode: 0644]
queue-6.6/series
queue-6.6/tools-testing-add-linux-args.h-header-and-fix-radix-vma-tests.patch [new file with mode: 0644]

diff --git a/queue-6.6/selftests-bpf-add-simple-strscpy-implementation.patch b/queue-6.6/selftests-bpf-add-simple-strscpy-implementation.patch
new file mode 100644 (file)
index 0000000..d5ca8cf
--- /dev/null
@@ -0,0 +1,133 @@
+From stable+bounces-288665-greg=kroah.com@vger.kernel.org Fri Jul 24 09:59:46 2026
+From: Shung-Hsi Yu <shung-hsi.yu@suse.com>
+Date: Fri, 24 Jul 2026 15:48:34 +0800
+Subject: selftests/bpf: Add simple strscpy() implementation
+To: stable@vger.kernel.org
+Cc: Shung-Hsi Yu <shung-hsi.yu@suse.com>, Lorenzo Stoakes <lorenzo.stoakes@oracle.com>, Jann Horn <jannh@google.com>, John Hubbard <jhubbard@nvidia.com>, Liam Howlett <liam.howlett@oracle.com>, Sidhartha Kumar <sidhartha.kumar@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, Dan Williams <dan.j.williams@intel.com>, Peter Zijlstra <peterz@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, Ihor Solodrai <ihor.solodrai@linux.dev>, Alexei Starovoitov <ast@kernel.org>
+Message-ID: <20260724074835.47479-2-shung-hsi.yu@suse.com>
+
+From: Ihor Solodrai <ihor.solodrai@linux.dev>
+
+commit 63c49efc987afefc6b9bb7de083eb8748e0b1789 upstream.
+
+Replace bpf_strlcpy() in bpf_util.h with a sized_strscpy(), which is a
+simplified sized_strscpy() from the kernel (lib/string.c [1]). It:
+  * takes a count (destination size) parameter
+  * guarantees NULL-termination
+  * returns the number of characters copied or -E2BIG
+
+Re-define strscpy macro similar to in-kernel implementation [2]: allow
+the count parameter to be optional.
+
+Add #ifdef-s to tools/include/linux/args.h, as they may be defined in
+other system headers (for example, __CONCAT in sys/cdefs.h).
+
+Fixup the single existing bpf_strlcpy() call in cgroup_helpers.c
+
+[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/string.c?h=v6.19#n113
+[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/string.h?h=v6.19#n91
+
+Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
+Link: https://lore.kernel.org/r/20260223190736.649171-2-ihor.solodrai@linux.dev
+Signed-off-by: Alexei Starovoitov <ast@kernel.org>
+Stable-dep-of: 55ffbe8a15b1 ("selftests/bpf: Initialize operation name before use")
+Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/include/linux/args.h                   |    4 ++
+ tools/testing/selftests/bpf/bpf_util.h       |   45 +++++++++++++++++++--------
+ tools/testing/selftests/bpf/cgroup_helpers.c |    2 -
+ 3 files changed, 37 insertions(+), 14 deletions(-)
+
+--- a/tools/include/linux/args.h
++++ b/tools/include/linux/args.h
+@@ -22,7 +22,11 @@
+ #define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+ /* Concatenate two parameters, but allow them to be expanded beforehand. */
++#ifndef __CONCAT
+ #define __CONCAT(a, b) a ## b
++#endif
++#ifndef CONCATENATE
+ #define CONCATENATE(a, b) __CONCAT(a, b)
++#endif
+ #endif        /* _LINUX_ARGS_H */
+--- a/tools/testing/selftests/bpf/bpf_util.h
++++ b/tools/testing/selftests/bpf/bpf_util.h
+@@ -7,6 +7,7 @@
+ #include <string.h>
+ #include <errno.h>
+ #include <bpf/libbpf.h> /* libbpf_num_possible_cpus */
++#include <linux/args.h>
+ static inline unsigned int bpf_num_possible_cpus(void)
+ {
+@@ -20,25 +21,43 @@ static inline unsigned int bpf_num_possi
+       return possible_cpus;
+ }
+-/* Copy up to sz - 1 bytes from zero-terminated src string and ensure that dst
+- * is zero-terminated string no matter what (unless sz == 0, in which case
+- * it's a no-op). It's conceptually close to FreeBSD's strlcpy(), but differs
+- * in what is returned. Given this is internal helper, it's trivial to extend
+- * this, when necessary. Use this instead of strncpy inside libbpf source code.
++/*
++ * Simplified strscpy() implementation. The kernel one is in lib/string.c
+  */
+-static inline void bpf_strlcpy(char *dst, const char *src, size_t sz)
++static inline ssize_t sized_strscpy(char *dest, const char *src, size_t count)
+ {
+-      size_t i;
++      long res = 0;
+-      if (sz == 0)
+-              return;
++      if (count == 0)
++              return -E2BIG;
+-      sz--;
+-      for (i = 0; i < sz && src[i]; i++)
+-              dst[i] = src[i];
+-      dst[i] = '\0';
++      while (count > 1) {
++              char c;
++
++              c = src[res];
++              dest[res] = c;
++              if (!c)
++                      return res;
++              res++;
++              count--;
++      }
++
++      /* Force NUL-termination. */
++      dest[res] = '\0';
++
++      /* Return E2BIG if the source didn't stop */
++      return src[res] ? -E2BIG : res;
+ }
++#define __strscpy0(dst, src, ...)     \
++      sized_strscpy(dst, src, sizeof(dst))
++#define __strscpy1(dst, src, size)    \
++      sized_strscpy(dst, src, size)
++
++#undef strscpy /* Redefine the placeholder from tools/include/linux/string.h */
++#define strscpy(dst, src, ...)        \
++      CONCATENATE(__strscpy, COUNT_ARGS(__VA_ARGS__))(dst, src, __VA_ARGS__)
++
+ #define __bpf_percpu_val_align        __attribute__((__aligned__(8)))
+ #define BPF_DECLARE_PERCPU(type, name)                                \
+--- a/tools/testing/selftests/bpf/cgroup_helpers.c
++++ b/tools/testing/selftests/bpf/cgroup_helpers.c
+@@ -78,7 +78,7 @@ static int __enable_controllers(const ch
+               enable[len] = 0;
+               close(fd);
+       } else {
+-              bpf_strlcpy(enable, controllers, sizeof(enable));
++              strscpy(enable, controllers);
+       }
+       snprintf(path, sizeof(path), "%s/cgroup.subtree_control", cgroup_path);
index 8553c6ec489ae01e52908fbe46d004111350263b..de1a5d662444b5e3a5d4c50402f5e1fc6d5d07a2 100644 (file)
@@ -1221,3 +1221,5 @@ jiffies-define-secs_to_jiffies.patch
 jiffies-cast-to-unsigned-long-in-secs_to_jiffies-conversion.patch
 driver-core-fix-missing-jiffies-conversion-in-deferred_probe_extend_timeout.patch
 driver-core-guard-deferred-probe-timeout-extension-with-delayed_work_pending.patch
+tools-testing-add-linux-args.h-header-and-fix-radix-vma-tests.patch
+selftests-bpf-add-simple-strscpy-implementation.patch
diff --git a/queue-6.6/tools-testing-add-linux-args.h-header-and-fix-radix-vma-tests.patch b/queue-6.6/tools-testing-add-linux-args.h-header-and-fix-radix-vma-tests.patch
new file mode 100644 (file)
index 0000000..28952fd
--- /dev/null
@@ -0,0 +1,83 @@
+From stable+bounces-288664-greg=kroah.com@vger.kernel.org Fri Jul 24 09:54:24 2026
+From: Shung-Hsi Yu <shung-hsi.yu@suse.com>
+Date: Fri, 24 Jul 2026 15:48:33 +0800
+Subject: tools/testing: add linux/args.h header and fix radix, VMA tests
+To: stable@vger.kernel.org
+Cc: Shung-Hsi Yu <shung-hsi.yu@suse.com>, Lorenzo Stoakes <lorenzo.stoakes@oracle.com>, Jann Horn <jannh@google.com>, John Hubbard <jhubbard@nvidia.com>, Liam Howlett <liam.howlett@oracle.com>, Sidhartha Kumar <sidhartha.kumar@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, Dan Williams <dan.j.williams@intel.com>, Peter Zijlstra <peterz@infradead.org>, Andrew Morton <akpm@linux-foundation.org>
+Message-ID: <20260724074835.47479-1-shung-hsi.yu@suse.com>
+
+From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
+
+commit 9a6a6a3191574a01dcf7a7d9385246d7bc8736bc upstream.
+
+Commit 857d18f23ab1 ("cleanup: Introduce ACQUIRE() and ACQUIRE_ERR() for
+conditional locks") accidentally broke the radix tree, VMA userland tests
+by including linux/args.h which is not present in the tools/include
+directory.
+
+This patch copies this over and adds an #ifdef block to avoid duplicate
+__CONCAT declaration in conflict with system headers when we ultimately
+include this.
+
+Link: https://lkml.kernel.org/r/20250811052654.33286-1-lorenzo.stoakes@oracle.com
+Fixes: 857d18f23ab1 ("cleanup: Introduce ACQUIRE() and ACQUIRE_ERR() for conditional locks")
+Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
+Cc: Jann Horn <jannh@google.com>
+Cc: John Hubbard <jhubbard@nvidia.com>
+Cc: Liam Howlett <liam.howlett@oracle.com>
+Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
+Cc: Vlastimil Babka <vbabka@suse.cz>
+Cc: Dan Williams <dan.j.williams@intel.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Stable-dep-of: 63c49efc987a ("selftests/bpf: Add simple strscpy() implementation")
+[shung-hsi.yu: tools/testing/shared/linux/idr.h was
+tools/testing/radix-tree/linux/idr.h before commit 579d8dab47 ("tools: separate
+out shared radix-tree components"). ]
+Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/include/linux/args.h           |   28 ++++++++++++++++++++++++++++
+ tools/testing/radix-tree/linux/idr.h |    4 ++++
+ 2 files changed, 32 insertions(+)
+ create mode 100644 tools/include/linux/args.h
+
+--- /dev/null
++++ b/tools/include/linux/args.h
+@@ -0,0 +1,28 @@
++/* SPDX-License-Identifier: GPL-2.0 */
++
++#ifndef _LINUX_ARGS_H
++#define _LINUX_ARGS_H
++
++/*
++ * How do these macros work?
++ *
++ * In __COUNT_ARGS() _0 to _12 are just placeholders from the start
++ * in order to make sure _n is positioned over the correct number
++ * from 12 to 0 (depending on X, which is a variadic argument list).
++ * They serve no purpose other than occupying a position. Since each
++ * macro parameter must have a distinct identifier, those identifiers
++ * are as good as any.
++ *
++ * In COUNT_ARGS() we use actual integers, so __COUNT_ARGS() returns
++ * that as _n.
++ */
++
++/* This counts to 15. Any more, it will return 16th argument. */
++#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _n, X...) _n
++#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
++
++/* Concatenate two parameters, but allow them to be expanded beforehand. */
++#define __CONCAT(a, b) a ## b
++#define CONCATENATE(a, b) __CONCAT(a, b)
++
++#endif        /* _LINUX_ARGS_H */
+--- a/tools/testing/radix-tree/linux/idr.h
++++ b/tools/testing/radix-tree/linux/idr.h
+@@ -1 +1,5 @@
++/* Avoid duplicate definitions due to system headers. */
++#ifdef __CONCAT
++#undef __CONCAT
++#endif
+ #include "../../../../include/linux/idr.h"