linux-stable/arch
Masahiro Yamada c4f7f31b3a Revert "[PATCH] uml: export symbols added by GCC hardened"
[ Upstream commit 8635e8df47 ]

This reverts commit cead61a671.

It exported __stack_smash_handler and __guard, while they may not be
defined by anyone.

The code *declares* __stack_smash_handler and __guard. It does not
create weak symbols. If no external library is linked, they are left
undefined, but yet exported.

If a loadable module tries to access non-existing symbols, bad things
(a page fault, NULL pointer dereference, etc.) will happen. So, the
current code is wrong and dangerous.

If the code were written as follows, it would *define* them as weak
symbols so modules would be able to get access to them.

  void (*__stack_smash_handler)(void *) __attribute__((weak));
  EXPORT_SYMBOL(__stack_smash_handler);

  long __guard __attribute__((weak));
  EXPORT_SYMBOL(__guard);

In fact, modpost forbids exporting undefined symbols. It shows an error
message if it detects such a mistake.

  ERROR: modpost: "..." [...] was exported without definition

Unfortunately, it is checked only when the code is built as modular.
The problem described above has been unnoticed for a long time because
arch/um/os-Linux/user_syms.c is always built-in.

With a planned change in Kbuild, exporting undefined symbols will always
result in a build error instead of a run-time error. It is a good thing,
but we need to fix the breakage in advance.

One fix is to define weak symbols as shown above. An alternative is to
export them conditionally as follows:

  #ifdef CONFIG_STACKPROTECTOR
  extern void __stack_smash_handler(void *);
  EXPORT_SYMBOL(__stack_smash_handler);

  external long __guard;
  EXPORT_SYMBOL(__guard);
  #endif

This is what other architectures do; EXPORT_SYMBOL(__stack_chk_guard)
is guarded by #ifdef CONFIG_STACKPROTECTOR.

However, adding the #ifdef guard is not sensible because UML cannot
enable the stack-protector in the first place! (Please note UML does
not select HAVE_STACKPROTECTOR in Kconfig.)

So, the code is already broken (and unused) in multiple ways.

Just remove.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-08-23 17:32:29 +02:00
..
alpha alpha: remove __init annotation from exported page_is_ram() 2023-08-16 18:32:31 +02:00
arc ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard 2023-07-19 16:36:19 +02:00
arm ARM: dts: imx6dl: prtrvt, prtvt7, prti6q, prtwd2: fix USB related warnings 2023-08-23 17:32:26 +02:00
arm64 arm64: dts: qcom: ipq5332: add QFPROM node 2023-08-23 17:32:25 +02:00
csky csky: fix up lock_mm_and_find_vma() conversion 2023-07-01 13:12:41 +02:00
hexagon mm/fault: convert remaining simple cases to lock_mm_and_find_vma() 2023-07-01 13:12:39 +02:00
ia64 ia64/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:04:48 +02:00
loongarch loongarch/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:04:48 +02:00
m68k m68k/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:04:48 +02:00
microblaze mm: always expand the stack with the mmap write lock held 2023-07-01 13:12:40 +02:00
mips mips/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:04:48 +02:00
nios2 mm/fault: convert remaining simple cases to lock_mm_and_find_vma() 2023-07-01 13:12:39 +02:00
openrisc openrisc: Union fpcsr and oldmask in sigcontext to unbreak userspace ABI 2023-07-23 13:53:45 +02:00
parisc parisc: Fix lightweight spinlock checks to not break futexes 2023-08-16 18:32:18 +02:00
powerpc powerpc/mm/altmap: Fix altmap boundary check 2023-08-11 12:14:27 +02:00
riscv riscv: mm: fix 2 instances of -Wmissing-variable-declarations 2023-08-16 18:32:18 +02:00
s390 KVM: s390: fix sthyi error handling 2023-08-11 12:14:08 +02:00
sh sh/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:04:49 +02:00
sparc sparc/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:04:49 +02:00
um Revert "[PATCH] uml: export symbols added by GCC hardened" 2023-08-23 17:32:29 +02:00
x86 x86: Move gds_ucode_mitigated() declaration to header 2023-08-16 18:32:22 +02:00
xtensa init: Remove check_bugs() leftovers 2023-08-08 20:04:49 +02:00
.gitignore
Kconfig init: Provide arch_cpu_finalize_init() 2023-08-08 20:04:47 +02:00