android_kernel_samsung_a7y1.../arch/mips
Paul Burton c6bc91ea01 MIPS: Avoid VDSO ABI breakage due to global register variable
commit bbcc5672b0063b0e9d65dc8787a4f09c3b5bb5cc upstream.

Declaring __current_thread_info as a global register variable has the
effect of preventing GCC from saving & restoring its value in cases
where the ABI would typically do so.

To quote GCC documentation:

> If the register is a call-saved register, call ABI is affected: the
> register will not be restored in function epilogue sequences after the
> variable has been assigned. Therefore, functions cannot safely return
> to callers that assume standard ABI.

When our position independent VDSO is built for the n32 or n64 ABIs all
functions it exposes should be preserving the value of $gp/$28 for their
caller, but in the presence of the __current_thread_info global register
variable GCC stops doing so & simply clobbers $gp/$28 when calculating
the address of the GOT.

In cases where the VDSO returns success this problem will typically be
masked by the caller in libc returning & restoring $gp/$28 itself, but
that is by no means guaranteed. In cases where the VDSO returns an error
libc will typically contain a fallback path which will now fail
(typically with a bad memory access) if it attempts anything which
relies upon the value of $gp/$28 - eg. accessing anything via the GOT.

One fix for this would be to move the declaration of
__current_thread_info inside the current_thread_info() function,
demoting it from global register variable to local register variable &
avoiding inadvertently creating a non-standard calling ABI for the VDSO.
Unfortunately this causes issues for clang, which doesn't support local
register variables as pointed out by commit fe92da0f355e ("MIPS: Changed
current_thread_info() to an equivalent supported by both clang and GCC")
which introduced the global register variable before we had a VDSO to
worry about.

Instead, fix this by continuing to use the global register variable for
the kernel proper but declare __current_thread_info as a simple extern
variable when building the VDSO. It should never be referenced, and will
cause a link error if it is. This resolves the calling convention issue
for the VDSO without having any impact upon the build of the kernel
itself for either clang or gcc.

Signed-off-by: Paul Burton <paulburton@kernel.org>
Fixes: ebb5e78cc634 ("MIPS: Initial implementation of a VDSO")
Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Tested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christian Brauner <christian.brauner@canonical.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: <stable@vger.kernel.org> # v4.4+
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-07 13:24:38 +02:00
..
alchemy A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ar7 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ath25 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ath79 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bcm47xx MIPS: BCM47XX: Enable USB power on Netgear WNDR3400v3 2020-04-07 12:26:48 +02:00
bcm63xx MIPS: BCM63XX: fix switch core reset on BCM6368 2020-04-07 11:59:41 +02:00
bmips A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
boot MIPS: fix build on non-linux hosts 2020-04-06 19:53:59 +02:00
cavium-octeon MIPS: OCTEON: cvmx_pko_mem_debug8: use oldest forward compatible definition 2020-04-07 12:45:27 +02:00
cobalt A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
configs USB: rio500: Remove Rio 500 kernel driver 2020-04-07 08:08:28 +02:00
dec A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
emma A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
fw MIPS: fw: sni: Fix out of bounds init of o32 stack 2020-04-07 09:27:50 +02:00
generic A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
include MIPS: Avoid VDSO ABI breakage due to global register variable 2020-04-07 13:24:38 +02:00
jazz A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
jz4740 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
kernel MIPS: bmips: mark exception vectors as char arrays 2020-04-07 09:29:11 +02:00
kvm A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
lantiq MIPS: lantiq: Fix bitfield masking 2020-04-06 20:26:48 +02:00
lasat A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
lib A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
loongson32 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
loongson64 mips: Loongson: Fix the link time qualifier of 'serial_exit()' 2020-04-07 09:24:10 +02:00
math-emu A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mm A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mti-malta A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mti-sead3 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
net A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
netlogic A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
oprofile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
paravirt A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pci A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pistachio MIPS: pistachio: Build uImage.gz by default 2020-04-06 18:45:16 +02:00
pmcs-msp71xx A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
pnx833x A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
power A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ralink A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
rb532 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sgi-ip22 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sgi-ip27 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sgi-ip32 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sibyte Revert "MIPS: SiByte: Enable swiotlb for SWARM, LittleSur and BigSur" 2020-04-06 21:35:31 +02:00
sni A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
txx9 mips: txx9: fix iounmap related issue 2020-04-07 12:27:07 +02:00
vdso MIPS: VDSO: Use same -m%-float cflag as the kernel proper 2020-04-06 21:35:45 +02:00
vr41xx A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
xilfpga A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kbuild A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kbuild.platforms A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig MIPS: SiByte: Enable ZONE_DMA32 for LittleSur 2020-04-07 12:44:27 +02:00
Kconfig.debug A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30