linux/arch/x86
Andy Lutomirski 3fb0fdb3bb x86/stackprotector/32: Make the canary into a regular percpu variable
On 32-bit kernels, the stackprotector canary is quite nasty -- it is
stored at %gs:(20), which is nasty because 32-bit kernels use %fs for
percpu storage.  It's even nastier because it means that whether %gs
contains userspace state or kernel state while running kernel code
depends on whether stackprotector is enabled (this is
CONFIG_X86_32_LAZY_GS), and this setting radically changes the way
that segment selectors work.  Supporting both variants is a
maintenance and testing mess.

Merely rearranging so that percpu and the stack canary
share the same segment would be messy as the 32-bit percpu address
layout isn't currently compatible with putting a variable at a fixed
offset.

Fortunately, GCC 8.1 added options that allow the stack canary to be
accessed as %fs:__stack_chk_guard, effectively turning it into an ordinary
percpu variable.  This lets us get rid of all of the code to manage the
stack canary GDT descriptor and the CONFIG_X86_32_LAZY_GS mess.

(That name is special.  We could use any symbol we want for the
 %fs-relative mode, but for CONFIG_SMP=n, gcc refuses to let us use any
 name other than __stack_chk_guard.)

Forcibly disable stackprotector on older compilers that don't support
the new options and turn the stack canary into a percpu variable. The
"lazy GS" approach is now used for all 32-bit configurations.

Also makes load_gs_index() work on 32-bit kernels. On 64-bit kernels,
it loads the GS selector and updates the user GSBASE accordingly. (This
is unchanged.) On 32-bit kernels, it loads the GS selector and updates
GSBASE, which is now always the user base. This means that the overall
effect is the same on 32-bit and 64-bit, which avoids some ifdeffery.

 [ bp: Massage commit message. ]

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/c0ff7dba14041c7e5d1cae5d4df052f03759bef3.1613243844.git.luto@kernel.org
2021-03-08 13:19:05 +01:00
..
boot EFI updates collected by Ard Biesheuvel: 2020-12-24 12:40:07 -08:00
configs module: remove EXPORT_UNUSED_SYMBOL* 2021-02-08 12:28:07 +01:00
crypto crypto: aesni - release FPU during skcipher walk API calls 2021-01-22 14:58:04 +11:00
entry x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
events perf/x86/rapl: Fix psys-energy event on Intel SPR platform 2021-02-10 14:44:55 +01:00
hyperv iommu/hyperv: setup an IO-APIC IRQ remapping domain for root partition 2021-02-11 08:47:07 +00:00
ia32 x86/ia32_signal: Propagate __user annotation properly 2020-12-11 19:44:31 +01:00
include x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
kernel x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
kvm * Doc fixes 2021-03-04 11:26:17 -08:00
lib x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
math-emu treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
mm x86: fix seq_file iteration for pat/memtype.c 2021-02-26 09:41:05 -08:00
net bpf: Add per-program recursion prevention mechanism 2021-02-11 16:19:13 +01:00
pci Simple Firmware Interface (SFI) support removal for v5.12-rc1 2021-02-24 10:35:29 -08:00
platform x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
power x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
purgatory crypto: sha - split sha.h into sha1.h and sha2.h 2020-11-20 14:45:33 +11:00
ras
realmode x86/head/64: Don't call verify_cpu() on starting APs 2020-09-09 11:33:20 +02:00
tools Modules updates for v5.12 2021-02-23 10:15:33 -08:00
um um: remove process stub VMA 2021-02-12 21:37:38 +01:00
video
xen x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
.gitignore
Kbuild
Kconfig x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug x86, libnvdimm/test: Remove COPY_MC_TEST 2020-10-26 18:08:35 +01:00
Makefile x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
Makefile_32.cpu
Makefile.um