android_kernel_oneplus_msm8998/arch/arm64
Greg Hackmann 355cccb659 arm64: mm: check for upper PAGE_SHIFT bits in pfn_valid()
commit 5ad356eabc47d26a92140a0c4b20eba471c10de3 upstream.

ARM64's pfn_valid() shifts away the upper PAGE_SHIFT bits of the input
before seeing if the PFN is valid.  This leads to false positives when
some of the upper bits are set, but the lower bits match a valid PFN.

For example, the following userspace code looks up a bogus entry in
/proc/kpageflags:

    int pagemap = open("/proc/self/pagemap", O_RDONLY);
    int pageflags = open("/proc/kpageflags", O_RDONLY);
    uint64_t pfn, val;

    lseek64(pagemap, [...], SEEK_SET);
    read(pagemap, &pfn, sizeof(pfn));
    if (pfn & (1UL << 63)) {        /* valid PFN */
        pfn &= ((1UL << 55) - 1);   /* clear flag bits */
        pfn |= (1UL << 55);
        lseek64(pageflags, pfn * sizeof(uint64_t), SEEK_SET);
        read(pageflags, &val, sizeof(val));
    }

On ARM64 this causes the userspace process to crash with SIGSEGV rather
than reading (1 << KPF_NOPAGE).  kpageflags_read() treats the offset as
valid, and stable_page_flags() will try to access an address between the
user and kernel address ranges.

Fixes: c1cc155261 ("arm64: MMU initialisation")
Cc: stable@vger.kernel.org
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-05 09:18:38 +02:00
..
boot arm64: dts: add #cooling-cells to CPU nodes 2018-02-25 11:03:37 +01:00
configs
crypto
include arm64: lse: Add early clobbers to some input/output asm operands 2018-06-06 16:46:20 +02:00
kernel arm64: make secondary_start_kernel() notrace 2018-08-24 13:26:55 +02:00
kvm
lib
mm arm64: mm: check for upper PAGE_SHIFT bits in pfn_valid() 2018-09-05 09:18:38 +02:00
net
xen
Kconfig arm64: Add work around for Arm Cortex-A55 Erratum 1024718 2018-05-26 08:48:49 +02:00
Kconfig.debug
Kconfig.platforms ARM: tegra: select USB_ULPI from EHCI rather than platform 2018-02-25 11:03:51 +01:00
Makefile