linux/arch/mips
Alexander Lobakin 0aeaadc52b MIPS: fix fortify panic when copying asm exception handlers
[ Upstream commit d17b66417308996e7e64b270a3c7f3c1fbd4cfc8 ]

With KCFLAGS="-O3", I was able to trigger a fortify-source
memcpy() overflow panic on set_vi_srs_handler().
Although O3 level is not supported in the mainline, under some
conditions that may've happened with any optimization settings,
it's just a matter of inlining luck. The panic itself is correct,
more precisely, 50/50 false-positive and not at the same time.
From the one side, no real overflow happens. Exception handler
defined in asm just gets copied to some reserved places in the
memory.
But the reason behind is that C code refers to that exception
handler declares it as `char`, i.e. something of 1 byte length.
It's obvious that the asm function itself is way more than 1 byte,
so fortify logics thought we are going to past the symbol declared.
The standard way to refer to asm symbols from C code which is not
supposed to be called from C is to declare them as
`extern const u8[]`. This is fully correct from any point of view,
as any code itself is just a bunch of bytes (including 0 as it is
for syms like _stext/_etext/etc.), and the exact size is not known
at the moment of compilation.
Adjust the type of the except_vec_vi_*() and related variables.
Make set_handler() take `const` as a second argument to avoid
cast-away warnings and give a little more room for optimization.

Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-04-15 14:18:34 +02:00
..
alchemy MIPS: alchemy: xxs1500: add gpio-au1000.h header file 2021-06-03 08:59:16 +02:00
ar7
ath25
ath79
bcm47xx MIPS: BCM47XX: fix kconfig dependency bug for BCM47XX_BCMA 2020-12-30 11:51:07 +01:00
bcm63xx mips: bcm63xx: add support for clk_set_parent() 2022-01-27 09:19:40 +01:00
bmips
boot mips: disable branch profiling in boot/decompress.o 2021-07-20 16:10:53 +02:00
cavium-octeon MIPS: OCTEON: add put_device() after of_find_device_by_node() 2022-01-27 09:19:48 +01:00
cobalt
configs scsi: sr: remove references to BLK_DEV_SR_VENDOR, leave it enabled 2020-07-22 09:32:57 +02:00
crypto
dec mips: DEC: honor CONFIG_MIPS_FP_SUPPORT=n 2022-04-15 14:18:15 +02:00
emma
fw
generic MIPS: generic/yamon-dt: fix uninitialized variable error 2021-11-26 10:47:19 +01:00
include MIPS: fix fortify panic when copying asm exception handlers 2022-04-15 14:18:34 +02:00
jazz
jz4740
kernel MIPS: fix fortify panic when copying asm exception handlers 2022-04-15 14:18:34 +02:00
kvm KVM: MIPS: Change the definition of kvm type 2020-09-23 12:40:38 +02:00
lantiq mips: lantiq: add support for clk_set_parent() 2022-01-27 09:19:40 +01:00
lasat
lib MIPS: Fix kernel hang under FUNCTION_GRAPH_TRACER and PREEMPT_TRACER 2021-06-16 11:59:37 +02:00
loongson32
loongson64 MIPS: loongsoon64: Reserve memory below starting pfn to prevent Oops 2021-07-19 08:53:13 +02:00
math-emu
mm MIPS: c-r4k: Fix section mismatch for loongson2_sc_init 2021-03-04 10:26:19 +01:00
mti-malta MIPS: Malta: fix alignment of the devicetree buffer 2021-09-22 12:26:26 +02:00
net bpf, mips: Validate conditional branch offsets 2021-10-13 10:08:17 +02:00
netlogic
oprofile
paravirt
pci MIPS: pci-legacy: stop using of_pci_range_to_resource 2021-05-14 09:44:30 +02:00
pic32
pistachio
pmcs-msp71xx
pnx833x
power
ralink mips: ralink: fix a refcount leak in ill_acc_of_setup() 2022-04-15 14:18:34 +02:00
rb532 MIPS: RB532: fix return value of __setup handler 2022-04-15 14:18:16 +02:00
sgi-ip22
sgi-ip27
sgi-ip32
sibyte
sni MIPS: sni: Fix the build 2021-11-26 10:47:16 +01:00
tools
txx9
vdso MIPS: VDSO: Use CLANG_FLAGS instead of filtering out '--target=' 2021-03-07 12:20:41 +01:00
vr41xx
Kbuild
Kbuild.platforms
Kconfig MIPS: use 3-level pgtable for 64KB page size on MIPS_VA_BITS_48 2021-12-01 09:23:33 +01:00
Kconfig.debug
Makefile mips: Fix non-POSIX regexp 2021-08-12 13:20:57 +02:00
Makefile.postlink