* [PATCH 0/5] uapi: fix remaining kconfig leaks in UAPI headers
@ 2025-12-30 7:10 Thomas Weißschuh
2025-12-30 7:10 ` [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace Thomas Weißschuh
` (4 more replies)
0 siblings, 5 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2025-12-30 7:10 UTC (permalink / raw)
To: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel, Arnd Bergmann,
Thomas Weißschuh
A few UAPI headers still contained references to kconfig symbols.
Clean them all up and afterwards remove the now useless exception
machinery in headers_install.sh.
Intended to be routed through the kbuild tree.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Thomas Weißschuh (5):
ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace
ARM: uapi: Stop leaking CONFIG_CPU_ENDIAN_BE8 reference to userspace
nios2: uapi: Stop leaking CONFIG_NIOS2_CI_SWAB_{NO,SUPPORT} references to userspace
x86/uapi: Stop leaking kconfig references to userspace
scripts: headers_install.sh: Remove config leak ignore machinery
arch/arc/include/uapi/asm/swab.h | 2 +-
arch/arm/include/uapi/asm/ptrace.h | 2 +-
arch/nios2/include/uapi/asm/swab.h | 2 ++
arch/x86/include/uapi/asm/auxvec.h | 2 +-
scripts/headers_install.sh | 30 ++----------------------------
5 files changed, 7 insertions(+), 31 deletions(-)
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251229-headers_install-config-leak-b8a9219d8b3c
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace
2025-12-30 7:10 [PATCH 0/5] uapi: fix remaining kconfig leaks in UAPI headers Thomas Weißschuh
@ 2025-12-30 7:10 ` Thomas Weißschuh
2025-12-30 21:23 ` Arnd Bergmann
2025-12-30 7:10 ` [PATCH 2/5] ARM: uapi: Stop leaking CONFIG_CPU_ENDIAN_BE8 " Thomas Weißschuh
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Thomas Weißschuh @ 2025-12-30 7:10 UTC (permalink / raw)
To: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel, Arnd Bergmann,
Thomas Weißschuh
UAPI headers are not supposed to leak references to kconfig symbols.
These won't be set when building userspace. Hide the kconfig reference
behind 'if defined(__KERNEL__)', so it will be stripped by
headers_install.sh. The result for userspace will be the same, but the
exception in headers_install.sh can also be removed.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
| 2 +-
| 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
--git a/arch/arc/include/uapi/asm/swab.h b/arch/arc/include/uapi/asm/swab.h
index 8d1f1ef44ba7..b2cede1b74b9 100644
--- a/arch/arc/include/uapi/asm/swab.h
+++ b/arch/arc/include/uapi/asm/swab.h
@@ -20,7 +20,7 @@
#include <linux/types.h>
/* Native single cycle endian swap insn */
-#ifdef CONFIG_ARC_HAS_SWAPE
+#if defined(__KERNEL__) && defined(CONFIG_ARC_HAS_SWAPE)
#define __arch_swab32(x) \
({ \
--git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 0e4e939efc94..727f7f82c2c7 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -70,7 +70,6 @@ configs=$(sed -e '
#
# The format is <file-name>:<CONFIG-option> in each line.
config_leak_ignores="
-arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/5] ARM: uapi: Stop leaking CONFIG_CPU_ENDIAN_BE8 reference to userspace
2025-12-30 7:10 [PATCH 0/5] uapi: fix remaining kconfig leaks in UAPI headers Thomas Weißschuh
2025-12-30 7:10 ` [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace Thomas Weißschuh
@ 2025-12-30 7:10 ` Thomas Weißschuh
2025-12-30 14:20 ` Arnd Bergmann
2025-12-30 7:10 ` [PATCH 3/5] nios2: uapi: Stop leaking CONFIG_NIOS2_CI_SWAB_{NO,SUPPORT} references " Thomas Weißschuh
` (2 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Thomas Weißschuh @ 2025-12-30 7:10 UTC (permalink / raw)
To: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel, Arnd Bergmann,
Thomas Weißschuh
UAPI headers are not supposed to leak references to kconfig symbols.
These won't be set when building userspace. Hide the kconfig reference
behind 'if defined(__KERNEL__)', so it will be stripped by
headers_install.sh, the same way other kconfig references in this file
are handled. The result for userspace will be the same, but the
exception in headers_install.sh can also be removed.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
| 2 +-
| 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
--git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
index 8896c23ccba7..fe656da1701b 100644
--- a/arch/arm/include/uapi/asm/ptrace.h
+++ b/arch/arm/include/uapi/asm/ptrace.h
@@ -105,7 +105,7 @@
/*
* Default endianness state
*/
-#ifdef CONFIG_CPU_ENDIAN_BE8
+#if defined(__KERNEL__) && defined(CONFIG_CPU_ENDIAN_BE8)
#define PSR_ENDSTATE PSR_E_BIT
#else
#define PSR_ENDSTATE 0
--git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 727f7f82c2c7..4f03521f4026 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -70,7 +70,6 @@ configs=$(sed -e '
#
# The format is <file-name>:<CONFIG-option> in each line.
config_leak_ignores="
-arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/5] nios2: uapi: Stop leaking CONFIG_NIOS2_CI_SWAB_{NO,SUPPORT} references to userspace
2025-12-30 7:10 [PATCH 0/5] uapi: fix remaining kconfig leaks in UAPI headers Thomas Weißschuh
2025-12-30 7:10 ` [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace Thomas Weißschuh
2025-12-30 7:10 ` [PATCH 2/5] ARM: uapi: Stop leaking CONFIG_CPU_ENDIAN_BE8 " Thomas Weißschuh
@ 2025-12-30 7:10 ` Thomas Weißschuh
2025-12-30 21:19 ` Arnd Bergmann
2025-12-30 7:10 ` [PATCH 4/5] x86/uapi: Stop leaking kconfig " Thomas Weißschuh
2025-12-30 7:11 ` [PATCH 5/5] scripts: headers_install.sh: Remove config leak ignore machinery Thomas Weißschuh
4 siblings, 1 reply; 16+ messages in thread
From: Thomas Weißschuh @ 2025-12-30 7:10 UTC (permalink / raw)
To: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel, Arnd Bergmann,
Thomas Weißschuh
UAPI headers are not supposed to leak references to kconfig symbols.
These won't be set when building userspace. Hide the kconfig reference
behind 'ifdef __KERNEL__', so it will be stripped by
headers_install.sh. The result for userspace will be the same, but the
exceptions in headers_install.sh can also be removed.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
| 2 ++
| 2 --
2 files changed, 2 insertions(+), 2 deletions(-)
--git a/arch/nios2/include/uapi/asm/swab.h b/arch/nios2/include/uapi/asm/swab.h
index 9750547a5f82..bbfa9bd10b2f 100644
--- a/arch/nios2/include/uapi/asm/swab.h
+++ b/arch/nios2/include/uapi/asm/swab.h
@@ -14,6 +14,7 @@
#include <linux/types.h>
#include <asm-generic/swab.h>
+#ifdef __KERNEL__
#ifdef CONFIG_NIOS2_CI_SWAB_SUPPORT
#ifdef __GNUC__
@@ -34,5 +35,6 @@ static inline __attribute__((const)) __u32 __arch_swab32(__u32 x)
#endif /* __GNUC__ */
#endif /* CONFIG_NIOS2_CI_SWAB_SUPPORT */
+#endif /* __KERNEL__ */
#endif /* _ASM_NIOS2_SWAB_H */
--git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 4f03521f4026..613f400a67d1 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -70,8 +70,6 @@ configs=$(sed -e '
#
# The format is <file-name>:<CONFIG-option> in each line.
config_leak_ignores="
-arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
-arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
"
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/5] x86/uapi: Stop leaking kconfig references to userspace
2025-12-30 7:10 [PATCH 0/5] uapi: fix remaining kconfig leaks in UAPI headers Thomas Weißschuh
` (2 preceding siblings ...)
2025-12-30 7:10 ` [PATCH 3/5] nios2: uapi: Stop leaking CONFIG_NIOS2_CI_SWAB_{NO,SUPPORT} references " Thomas Weißschuh
@ 2025-12-30 7:10 ` Thomas Weißschuh
2025-12-30 21:08 ` Arnd Bergmann
2025-12-30 7:11 ` [PATCH 5/5] scripts: headers_install.sh: Remove config leak ignore machinery Thomas Weißschuh
4 siblings, 1 reply; 16+ messages in thread
From: Thomas Weißschuh @ 2025-12-30 7:10 UTC (permalink / raw)
To: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel, Arnd Bergmann,
Thomas Weißschuh
UAPI headers are not supposed to leak references to kconfig symbols.
These won't be set when building userspace. Hide the kconfig reference
behind 'if defined(__KERNEL__)', so it will be stripped by
headers_install.sh. The result for userspace will be the same, but the
exceptions in headers_install.sh can also be removed.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
| 2 +-
| 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
--git a/arch/x86/include/uapi/asm/auxvec.h b/arch/x86/include/uapi/asm/auxvec.h
index 6beb55bbefa4..bdde9e18f94e 100644
--- a/arch/x86/include/uapi/asm/auxvec.h
+++ b/arch/x86/include/uapi/asm/auxvec.h
@@ -11,7 +11,7 @@
#define AT_SYSINFO_EHDR 33
/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
+#if defined(__KERNEL__) && (defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64))
# define AT_VECTOR_SIZE_ARCH 3
#else /* else it's non-compat x86-64 */
# define AT_VECTOR_SIZE_ARCH 2
--git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 613f400a67d1..1301ba68d772 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -70,8 +70,6 @@ configs=$(sed -e '
#
# The format is <file-name>:<CONFIG-option> in each line.
config_leak_ignores="
-arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
-arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
"
for c in $configs
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 5/5] scripts: headers_install.sh: Remove config leak ignore machinery
2025-12-30 7:10 [PATCH 0/5] uapi: fix remaining kconfig leaks in UAPI headers Thomas Weißschuh
` (3 preceding siblings ...)
2025-12-30 7:10 ` [PATCH 4/5] x86/uapi: Stop leaking kconfig " Thomas Weißschuh
@ 2025-12-30 7:11 ` Thomas Weißschuh
4 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2025-12-30 7:11 UTC (permalink / raw)
To: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel, Arnd Bergmann,
Thomas Weißschuh
There are no entries left to ignore and none should be added again.
Remove the now unused logic.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
| 24 ++----------------------
1 file changed, 2 insertions(+), 22 deletions(-)
--git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 1301ba68d772..9c15e748761c 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -64,30 +64,10 @@ configs=$(sed -e '
d
' $OUTFILE)
-# The entries in the following list do not result in an error.
-# Please do not add a new entry. This list is only for existing ones.
-# The list will be reduced gradually, and deleted eventually. (hopefully)
-#
-# The format is <file-name>:<CONFIG-option> in each line.
-config_leak_ignores="
-"
-
for c in $configs
do
- leak_error=1
-
- for ignore in $config_leak_ignores
- do
- if echo "$INFILE:$c" | grep -q "$ignore$"; then
- leak_error=
- break
- fi
- done
-
- if [ "$leak_error" = 1 ]; then
- echo "error: $INFILE: leak $c to user-space" >&2
- exit 1
- fi
+ echo "error: $INFILE: leak $c to user-space" >&2
+ exit 1
done
rm -f $TMPFILE
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 2/5] ARM: uapi: Stop leaking CONFIG_CPU_ENDIAN_BE8 reference to userspace
2025-12-30 7:10 ` [PATCH 2/5] ARM: uapi: Stop leaking CONFIG_CPU_ENDIAN_BE8 " Thomas Weißschuh
@ 2025-12-30 14:20 ` Arnd Bergmann
2025-12-30 14:33 ` Thomas Weißschuh
0 siblings, 1 reply; 16+ messages in thread
From: Arnd Bergmann @ 2025-12-30 14:20 UTC (permalink / raw)
To: Thomas Weißschuh, Vineet Gupta, Russell King, Dinh Nguyen,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel
On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
> UAPI headers are not supposed to leak references to kconfig symbols.
> These won't be set when building userspace. Hide the kconfig reference
> behind 'if defined(__KERNEL__)', so it will be stripped by
> headers_install.sh, the same way other kconfig references in this file
> are handled. The result for userspace will be the same, but the
> exception in headers_install.sh can also be removed.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
According to codesearch.debian.net, there are no actual users of
this definition outside of the kernel, and there really shouldn't
be either.
It should be both safe and correct to open-code PSR_ENDSTATE
in the two file where it is used as
if (IS_ENABLED(CONFIG_CPU_ENDIAN_BE8))
regs->ARM_cpsr |= PSR_E_BIT
and then remove the definition from the header. Alternatively
it could be moved into the non-uapi header, or you can have
an #ifdef around both of them.
Arnd
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/5] ARM: uapi: Stop leaking CONFIG_CPU_ENDIAN_BE8 reference to userspace
2025-12-30 14:20 ` Arnd Bergmann
@ 2025-12-30 14:33 ` Thomas Weißschuh
0 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2025-12-30 14:33 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
linux-snps-arc, linux-kernel, linux-arm-kernel
On Tue, Dec 30, 2025 at 03:20:10PM +0100, Arnd Bergmann wrote:
> On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
> > UAPI headers are not supposed to leak references to kconfig symbols.
> > These won't be set when building userspace. Hide the kconfig reference
> > behind 'if defined(__KERNEL__)', so it will be stripped by
> > headers_install.sh, the same way other kconfig references in this file
> > are handled. The result for userspace will be the same, but the
> > exception in headers_install.sh can also be removed.
> >
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
>
> According to codesearch.debian.net, there are no actual users of
> this definition outside of the kernel, and there really shouldn't
> be either.
>
> It should be both safe and correct to open-code PSR_ENDSTATE
> in the two file where it is used as
>
> if (IS_ENABLED(CONFIG_CPU_ENDIAN_BE8))
> regs->ARM_cpsr |= PSR_E_BIT
>
> and then remove the definition from the header. Alternatively
> it could be moved into the non-uapi header, or you can have
> an #ifdef around both of them.
These alternatives work for me, too. I went with the current aproach as
it matches what the rest of the file is doing and it won't break users.
I'll do the open-coding as proposed above.
Thomas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/5] x86/uapi: Stop leaking kconfig references to userspace
2025-12-30 7:10 ` [PATCH 4/5] x86/uapi: Stop leaking kconfig " Thomas Weißschuh
@ 2025-12-30 21:08 ` Arnd Bergmann
2026-01-02 9:30 ` Thomas Weißschuh
0 siblings, 1 reply; 16+ messages in thread
From: Arnd Bergmann @ 2025-12-30 21:08 UTC (permalink / raw)
To: Thomas Weißschuh, Vineet Gupta, Russell King, Dinh Nguyen,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel
On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
>
> /* entries in ARCH_DLINFO: */
> -#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
> +#if defined(__KERNEL__) && (defined(CONFIG_IA32_EMULATION) ||
> !defined(CONFIG_X86_64))
> # define AT_VECTOR_SIZE_ARCH 3
> #else /* else it's non-compat x86-64 */
> # define AT_VECTOR_SIZE_ARCH 2
While this patch clearly keeps the current behavior, I think it's
wrong, and 32-bit userspace should see a '3' instead of '2' here.
It can probably just be '3' unconditionally, or we can
make it more complex and have a userspace definition based
on __x86_64__ being defined.
I also wonder if there is a problem with the third
x86-64 entry being zero rather than AT_IGNORE. I see that
some architectures do it like this, to keep the number constant
even if some entries are missing:
if (likely(signal_minsigstksz)) \
NEW_AUX_ENT(AT_MINSIGSTKSZ, signal_minsigstksz); \
else \
NEW_AUX_ENT(AT_IGNORE, 0); \
Arnd
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/5] nios2: uapi: Stop leaking CONFIG_NIOS2_CI_SWAB_{NO,SUPPORT} references to userspace
2025-12-30 7:10 ` [PATCH 3/5] nios2: uapi: Stop leaking CONFIG_NIOS2_CI_SWAB_{NO,SUPPORT} references " Thomas Weißschuh
@ 2025-12-30 21:19 ` Arnd Bergmann
0 siblings, 0 replies; 16+ messages in thread
From: Arnd Bergmann @ 2025-12-30 21:19 UTC (permalink / raw)
To: Thomas Weißschuh, Vineet Gupta, Russell King, Dinh Nguyen,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel
On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
> UAPI headers are not supposed to leak references to kconfig symbols.
> These won't be set when building userspace. Hide the kconfig reference
> behind 'ifdef __KERNEL__', so it will be stripped by
> headers_install.sh. The result for userspace will be the same, but the
> exceptions in headers_install.sh can also be removed.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/nios2/include/uapi/asm/swab.h | 2 ++
> scripts/headers_install.sh | 2 --
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/nios2/include/uapi/asm/swab.h
> b/arch/nios2/include/uapi/asm/swab.h
> index 9750547a5f82..bbfa9bd10b2f 100644
> --- a/arch/nios2/include/uapi/asm/swab.h
> +++ b/arch/nios2/include/uapi/asm/swab.h
> @@ -14,6 +14,7 @@
> #include <linux/types.h>
> #include <asm-generic/swab.h>
>
> +#ifdef __KERNEL__
> #ifdef CONFIG_NIOS2_CI_SWAB_SUPPORT
> #ifdef __GNUC__
>
I'm fairly sure this approach is correct, but I noticed
that this makes arch/nios2/include/uapi/asm/swab.h empty
in userspace, so you could just move the current file
to arch/nios2/include/asm/swab.h instead and fall back to
the asm-generic header for uapi.
Arnd
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace
2025-12-30 7:10 ` [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace Thomas Weißschuh
@ 2025-12-30 21:23 ` Arnd Bergmann
2026-01-02 7:55 ` Thomas Weißschuh
2026-01-02 21:53 ` Vineet Gupta
0 siblings, 2 replies; 16+ messages in thread
From: Arnd Bergmann @ 2025-12-30 21:23 UTC (permalink / raw)
To: Thomas Weißschuh, Vineet Gupta, Russell King, Dinh Nguyen,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel
On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
> UAPI headers are not supposed to leak references to kconfig symbols.
> These won't be set when building userspace. Hide the kconfig reference
> behind 'if defined(__KERNEL__)', so it will be stripped by
> headers_install.sh. The result for userspace will be the same, but the
> exception in headers_install.sh can also be removed.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Same as for the nios2 version, I think the nicer solution would
be to use the asm-generic header for uapi and move this one
to arch/arc/include/asm/swab.h for kernel-internal use.
In theory, using 'select ARCH_USE_BUILTIN_BSWAP' in Kconfig should
let the compiler pick the best swap instruction, which would
be even less code, but I'm not sure if there was a reason that
nios2 and arc don't already do this.
Arnd
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace
2025-12-30 21:23 ` Arnd Bergmann
@ 2026-01-02 7:55 ` Thomas Weißschuh
2026-01-02 9:40 ` Thomas Weißschuh
2026-01-02 21:53 ` Vineet Gupta
1 sibling, 1 reply; 16+ messages in thread
From: Thomas Weißschuh @ 2026-01-02 7:55 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
linux-snps-arc, linux-kernel, linux-arm-kernel
On Tue, Dec 30, 2025 at 10:23:08PM +0100, Arnd Bergmann wrote:
> On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
> > UAPI headers are not supposed to leak references to kconfig symbols.
> > These won't be set when building userspace. Hide the kconfig reference
> > behind 'if defined(__KERNEL__)', so it will be stripped by
> > headers_install.sh. The result for userspace will be the same, but the
> > exception in headers_install.sh can also be removed.
> >
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
>
> Same as for the nios2 version, I think the nicer solution would
> be to use the asm-generic header for uapi and move this one
> to arch/arc/include/asm/swab.h for kernel-internal use.
Ack. Also to your other feedback on the series.
> In theory, using 'select ARCH_USE_BUILTIN_BSWAP' in Kconfig should
> let the compiler pick the best swap instruction, which would
> be even less code, but I'm not sure if there was a reason that
> nios2 and arc don't already do this.
I'd like to keep the current logic to avoid potential issues.
But maybe the arch maintainers will chime in.
Thomas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/5] x86/uapi: Stop leaking kconfig references to userspace
2025-12-30 21:08 ` Arnd Bergmann
@ 2026-01-02 9:30 ` Thomas Weißschuh
0 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-01-02 9:30 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
linux-snps-arc, linux-kernel, linux-arm-kernel
On Tue, Dec 30, 2025 at 10:08:04PM +0100, Arnd Bergmann wrote:
> On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
> >
> > /* entries in ARCH_DLINFO: */
> > -#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
> > +#if defined(__KERNEL__) && (defined(CONFIG_IA32_EMULATION) ||
> > !defined(CONFIG_X86_64))
> > # define AT_VECTOR_SIZE_ARCH 3
> > #else /* else it's non-compat x86-64 */
> > # define AT_VECTOR_SIZE_ARCH 2
>
> While this patch clearly keeps the current behavior, I think it's
> wrong, and 32-bit userspace should see a '3' instead of '2' here.
>
> It can probably just be '3' unconditionally, or we can
> make it more complex and have a userspace definition based
> on __x86_64__ being defined.
Does userspace even need to see this definition at all?
This value only makes sense in combination with AT_VECTOR_SIZE_BASE
which itself is not part of the UAPI. Debian codesearch did not bring
up a user for it. Not even CRIU, as they use their own definitions.
The value is wrong today on x86 and nobody seems to have noticed.
(Based on both the kconfig variables and the vDSO cmdline switches).
Also UML shares the same UAPI headers but in the kernel has its own
ARCH_DLINFO, so the values is "wrong" there, too.
> I also wonder if there is a problem with the third
> x86-64 entry being zero rather than AT_IGNORE. I see that
> some architectures do it like this, to keep the number constant
> even if some entries are missing:
>
> if (likely(signal_minsigstksz)) \
> NEW_AUX_ENT(AT_MINSIGSTKSZ, signal_minsigstksz); \
> else \
> NEW_AUX_ENT(AT_IGNORE, 0); \
>
> Arnd
The whole AUX_ENT handling seems brittle and slighly broken. Many changes to
AT_VECTOR_SIZE_BASE are done as fixes, as they were forgotten in the original
changes to the process setup code. The addition of AT_HWCAP3/AT_HWCAP4 is
still not reflected in AT_VECTOR_SIZE_BASE. (AT_HWCAP4 is never used anyways)
Then the same logic is duplicated between binfmt_elf.c and binfmt_elf_fdpic.c,
except that it is slightly different and the latter is missing some fields.
We should deduplicate this code and find a way add a static assertion.
Also space is wasted as more entries than possible are allocated in many cases.
For example AT_BASE_PLATFORM and AT_RSEQ_*. And those are not stubbed out with
AT_IGNORE either.
So I'd like to keep my current patch as is, to reach my current goal of getting
rid of kconfig leaks in the UAPI headers. In parallel we can remove
AT_VECTOR_SIZE_ARCH from the UAPI and fix the auxiliary vector handling in
two different patch series.
Thomas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace
2026-01-02 7:55 ` Thomas Weißschuh
@ 2026-01-02 9:40 ` Thomas Weißschuh
2026-01-02 10:31 ` Arnd Bergmann
0 siblings, 1 reply; 16+ messages in thread
From: Thomas Weißschuh @ 2026-01-02 9:40 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
linux-snps-arc, linux-kernel, linux-arm-kernel
On Fri, Jan 02, 2026 at 08:55:10AM +0100, Thomas Weißschuh wrote:
> On Tue, Dec 30, 2025 at 10:23:08PM +0100, Arnd Bergmann wrote:
> > On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
> > > UAPI headers are not supposed to leak references to kconfig symbols.
> > > These won't be set when building userspace. Hide the kconfig reference
> > > behind 'if defined(__KERNEL__)', so it will be stripped by
> > > headers_install.sh. The result for userspace will be the same, but the
> > > exception in headers_install.sh can also be removed.
> > >
> > > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> >
> > Acked-by: Arnd Bergmann <arnd@arndb.de>
> >
> > Same as for the nios2 version, I think the nicer solution would
> > be to use the asm-generic header for uapi and move this one
> > to arch/arc/include/asm/swab.h for kernel-internal use.
>
> Ack. (...)
This doesn't seem to be true. ARC does have a custom C implementation which
according to its comment is supposed to be more efficient than the generic one.
So I'd like to keep this as-is.
(...)
Thomas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace
2026-01-02 9:40 ` Thomas Weißschuh
@ 2026-01-02 10:31 ` Arnd Bergmann
0 siblings, 0 replies; 16+ messages in thread
From: Arnd Bergmann @ 2026-01-02 10:31 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Vineet Gupta, Russell King, Dinh Nguyen, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
linux-snps-arc, linux-kernel, linux-arm-kernel
On Fri, Jan 2, 2026, at 10:40, Thomas Weißschuh wrote:
> On Fri, Jan 02, 2026 at 08:55:10AM +0100, Thomas Weißschuh wrote:
>> On Tue, Dec 30, 2025 at 10:23:08PM +0100, Arnd Bergmann wrote:
>> > On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
>> > > UAPI headers are not supposed to leak references to kconfig symbols.
>> > > These won't be set when building userspace. Hide the kconfig reference
>> > > behind 'if defined(__KERNEL__)', so it will be stripped by
>> > > headers_install.sh. The result for userspace will be the same, but the
>> > > exception in headers_install.sh can also be removed.
>> > >
>> > > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
>> >
>> > Acked-by: Arnd Bergmann <arnd@arndb.de>
>> >
>> > Same as for the nios2 version, I think the nicer solution would
>> > be to use the asm-generic header for uapi and move this one
>> > to arch/arc/include/asm/swab.h for kernel-internal use.
>>
>> Ack. (...)
>
> This doesn't seem to be true. ARC does have a custom C implementation which
> according to its comment is supposed to be more efficient than the generic one.
> So I'd like to keep this as-is.
Right, though I see that since 767a697e7576 ("ARC: retire ARC750
support"), all supported CPUs do have the 'swape' instruction,
so I suppose we could just as well remove the CONFIG_ARC_HAS_SWAPE
symbol and just keep the inline asm version.
I also checked that for -mcpu=archs, the compiler uses swape
in __builtin_bswap32(), but it seems that there is no mcpu=arc770
option, and building for arc700 instead gets us the external
library call, which is likely worse than swape.
Arnd
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace
2025-12-30 21:23 ` Arnd Bergmann
2026-01-02 7:55 ` Thomas Weißschuh
@ 2026-01-02 21:53 ` Vineet Gupta
1 sibling, 0 replies; 16+ messages in thread
From: Vineet Gupta @ 2026-01-02 21:53 UTC (permalink / raw)
To: Arnd Bergmann, Thomas Weißschuh, Vineet Gupta, Russell King,
Dinh Nguyen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin
Cc: linux-snps-arc, linux-kernel, linux-arm-kernel
Hi Arnd,
Long time no see. Happy New Year !
On 12/30/25 13:23, Arnd Bergmann wrote:
> On Tue, Dec 30, 2025, at 08:10, Thomas Weißschuh wrote:
>> UAPI headers are not supposed to leak references to kconfig symbols.
>> These won't be set when building userspace. Hide the kconfig reference
>> behind 'if defined(__KERNEL__)', so it will be stripped by
>> headers_install.sh. The result for userspace will be the same, but the
>> exception in headers_install.sh can also be removed.
>>
>> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
>
> Same as for the nios2 version, I think the nicer solution would
> be to use the asm-generic header for uapi and move this one
> to arch/arc/include/asm/swab.h for kernel-internal use.
>
> In theory, using 'select ARCH_USE_BUILTIN_BSWAP' in Kconfig should
> let the compiler pick the best swap instruction, which would
> be even less code, but I'm not sure if there was a reason that
> nios2 and arc don't already do this.
The builtins didn't exist when the insns were first rolled out in hw.
It seems ARCH_USE_BUILTIN_BSWAP assumes 16,32,64 variants to be available which
surprisingly seems to be true.
foo32:
j_s.d [blink]
swape r0,r0
foo16:
exth_s r0,r0
asl r2,r0,8
lsr_s r0,r0,8
or_s r0,r0,r2
j_s.d [blink]
exth_s r0,r0
foo64:
mov_s r2,r1 ;4
swape r1,r0
j_s.d [blink]
swape r0,r2
And as you said, since all upstream cores support SWAPE, we can really get rid
of all the legacy stuff and just rely on builtins.
Thx,
-Vineet
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2026-01-02 21:53 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-30 7:10 [PATCH 0/5] uapi: fix remaining kconfig leaks in UAPI headers Thomas Weißschuh
2025-12-30 7:10 ` [PATCH 1/5] ARC: uapi: Stop leaking CONFIG_ARC_HAS_SWAPE reference to userspace Thomas Weißschuh
2025-12-30 21:23 ` Arnd Bergmann
2026-01-02 7:55 ` Thomas Weißschuh
2026-01-02 9:40 ` Thomas Weißschuh
2026-01-02 10:31 ` Arnd Bergmann
2026-01-02 21:53 ` Vineet Gupta
2025-12-30 7:10 ` [PATCH 2/5] ARM: uapi: Stop leaking CONFIG_CPU_ENDIAN_BE8 " Thomas Weißschuh
2025-12-30 14:20 ` Arnd Bergmann
2025-12-30 14:33 ` Thomas Weißschuh
2025-12-30 7:10 ` [PATCH 3/5] nios2: uapi: Stop leaking CONFIG_NIOS2_CI_SWAB_{NO,SUPPORT} references " Thomas Weißschuh
2025-12-30 21:19 ` Arnd Bergmann
2025-12-30 7:10 ` [PATCH 4/5] x86/uapi: Stop leaking kconfig " Thomas Weißschuh
2025-12-30 21:08 ` Arnd Bergmann
2026-01-02 9:30 ` Thomas Weißschuh
2025-12-30 7:11 ` [PATCH 5/5] scripts: headers_install.sh: Remove config leak ignore machinery Thomas Weißschuh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).