linux-stable/arch/mips
Paul Burton 3901e8368c MIPS: Bounds check virt_addr_valid
commit 074a1e1167 upstream.

The virt_addr_valid() function is meant to return true iff
virt_to_page() will return a valid struct page reference. This is true
iff the address provided is found within the unmapped address range
between PAGE_OFFSET & MAP_BASE, but we don't currently check for that
condition. Instead we simply mask the address to obtain what will be a
physical address if the virtual address is indeed in the desired range,
shift it to form a PFN & then call pfn_valid(). This can incorrectly
return true if called with a virtual address which, after masking,
happens to form a physical address corresponding to a valid PFN.

For example we may vmalloc an address in the kernel mapped region
starting a MAP_BASE & obtain the virtual address:

  addr = 0xc000000000002000

When masked by virt_to_phys(), which uses __pa() & in turn CPHYSADDR(),
we obtain the following (bogus) physical address:

  addr = 0x2000

In a common system with PHYS_OFFSET=0 this will correspond to a valid
struct page which should really be accessed by virtual address
PAGE_OFFSET+0x2000, causing virt_addr_valid() to incorrectly return 1
indicating that the original address corresponds to a struct page.

This is equivalent to the ARM64 change made in commit ca219452c6
("arm64: Correctly bounds check virt_addr_valid").

This fixes fallout when hardened usercopy is enabled caused by the
related commit 517e1fbeb6 ("mm/usercopy: Drop extra
is_vmalloc_or_module() check") which removed a check for the vmalloc
range that was present from the introduction of the hardened usercopy
feature.

Signed-off-by: Paul Burton <paul.burton@mips.com>
References: ca219452c6 ("arm64: Correctly bounds check virt_addr_valid")
References: 517e1fbeb6 ("mm/usercopy: Drop extra is_vmalloc_or_module() check")
Reported-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: YunQiang Su <ysu@wavecomp.com>
URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=929366
Cc: stable@vger.kernel.org # v4.12+
Cc: linux-mips@vger.kernel.org
Cc: Yunqiang Su <ysu@wavecomp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-11 12:21:48 +02:00
..
alchemy License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ar7 MIPS: AR7: ensure the port type's FCR value is used 2018-01-23 19:58:21 +01:00
ath25 MIPS: ath25: Check for kzalloc allocation failure 2018-03-15 10:54:31 +01:00
ath79 MIPS: perf: ath79: Fix perfcount IRQ assignment 2019-05-16 19:42:23 +02:00
bcm47xx Revert "MIPS: BCM47XX: Enable 74K Core ExternalSync for PCIe erratum" 2018-09-05 09:26:30 +02:00
bcm63xx License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bmips License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
boot DTS: CI20: Fix bugs in ci20's device tree. 2019-03-13 14:03:20 -07:00
cavium-octeon MIPS: OCTEON: mark RGMII interface disabled on OCTEON III 2019-01-09 17:14:52 +01:00
cobalt
configs MIPS: ath79: Enable OF serial ports in the default config 2019-02-27 10:08:04 +01:00
dec License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
emma
fw License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
generic MIPS: generic: fix missing of_node_put() 2018-09-19 22:43:43 +02:00
include MIPS: VDSO: Reduce VDSO_RANDOMIZE_SIZE to 64MB for 64bit 2019-05-16 19:42:25 +02:00
jazz MIPS: jazz: fix 64bit build 2019-02-27 10:08:04 +01:00
jz4740 MIPS: jz4740: Bump zload address 2018-09-26 08:38:03 +02:00
kernel MIPS: KGDB: fix kgdb support for SMP platforms. 2019-05-10 17:53:09 +02:00
kvm KVM: s390: Do not report unusabled IDs via KVM_CAP_MAX_VCPU_ID 2019-06-09 09:18:16 +02:00
lantiq MIPS: lantiq: Fix IPI interrupt handling 2019-01-23 08:09:48 +01:00
lasat License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lib MIPS: lib: Provide MIPS64r6 __multi3() for GCC < 7 2018-09-05 09:26:41 +02:00
loongson32 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
loongson64 mips: loongson64: lemote-2f: Add IRQF_NO_SUSPEND to "cascade" irqaction. 2019-03-27 14:13:52 +09:00
math-emu MIPS: math-emu: Write-protect delay slot emulation pages 2019-01-09 17:14:51 +01:00
mm MIPS: Bounds check virt_addr_valid 2019-06-11 12:21:48 +02:00
mti-malta Update MIPS email addresses 2017-11-03 09:02:30 -07:00
net MIPS: eBPF: Fix icache flush end address 2019-03-05 17:58:03 +01:00
netlogic License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
oprofile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
paravirt License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pci MIPS: OCTEON: don't set octeon_dma_bar_type if PCI is disabled 2019-02-15 08:09:12 +01:00
pic32 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pistachio License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pmcs-msp71xx License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pnx833x mtd: nand: Rename nand.h into rawnand.h 2017-08-13 10:11:49 +02:00
power License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ralink MIPS: ralink: Select CONFIG_CPU_MIPSR2_IRQ_VI on MT7620/8 2019-02-12 19:46:08 +01:00
rb532 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sgi-ip22 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sgi-ip27 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sgi-ip32
sibyte MIPS: SiByte: Enable swiotlb for SWARM, LittleSur and BigSur 2019-01-26 09:37:01 +01:00
sni License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tools Update MIPS email addresses 2017-11-03 09:02:30 -07:00
txx9 MIPS: TXx9: use IS_BUILTIN() for CONFIG_LEDS_CLASS 2018-04-26 11:02:17 +02:00
vdso MIPS: VDSO: Include $(ccflags-vdso) in o32,n32 .lds builds 2019-02-15 08:09:12 +01:00
vr41xx License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xilfpga License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kbuild
Kbuild.platforms
Kconfig MIPS: SiByte: Enable swiotlb for SWARM, LittleSur and BigSur 2019-01-26 09:37:01 +01:00
Kconfig.debug License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile MIPS: Always use -march=<arch>, not -<arch> shortcuts 2018-09-05 09:26:41 +02:00
Makefile.postlink License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00