--- /dev/null
+From stable+bounces-288213-greg=kroah.com@vger.kernel.org Thu Jul 23 09:20:03 2026
+From: Shung-Hsi Yu <shung-hsi.yu@suse.com>
+Date: Thu, 23 Jul 2026 15:13:32 +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: <20260723071334.39630-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")
+Closes: https://lore.kernel.org/stable/al8dSv_OvhwxFCar@u94a
+Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+Confirmed that BPF selftests successfully builds on 6.12[1] and 6.6[2]
+after this patchset is applied.
+
+1: https://github.com/kernel-patches/linux-stable/actions/runs/29986297264
+2: https://github.com/kernel-patches/linux-stable/actions/runs/29987147891/
+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
+@@ -8,6 +8,7 @@
+ #include <errno.h>
+ #include <syscall.h>
+ #include <bpf/libbpf.h> /* libbpf_num_possible_cpus */
++#include <linux/args.h>
+
+ static inline unsigned int bpf_num_possible_cpus(void)
+ {
+@@ -21,25 +22,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
+@@ -85,7 +85,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);
--- /dev/null
+From stable+bounces-288212-greg=kroah.com@vger.kernel.org Thu Jul 23 09:15:47 2026
+From: Shung-Hsi Yu <shung-hsi.yu@suse.com>
+Date: Thu, 23 Jul 2026 15:13:31 +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: <20260723071334.39630-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")
+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/shared/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/shared/linux/idr.h
++++ b/tools/testing/shared/linux/idr.h
+@@ -1 +1,5 @@
++/* Avoid duplicate definitions due to system headers. */
++#ifdef __CONCAT
++#undef __CONCAT
++#endif
+ #include "../../../../include/linux/idr.h"