diff options
| author | Greg Hackmann <ghackmann@android.com> | 2018-08-15 12:51:21 -0700 | 
|---|---|---|
| committer | Will Deacon <will.deacon@arm.com> | 2018-08-17 10:27:14 +0100 | 
| commit | 5ad356eabc47d26a92140a0c4b20eba471c10de3 (patch) | |
| tree | 7a29e934fefae3a9d0d655e86d8b1f399388191b /arch/powerpc/include/asm/code-patching-asm.h | |
| parent | f6cc0c50164994afd538911603b4a8f8029aeba7 (diff) | |
arm64: mm: check for upper PAGE_SHIFT bits in pfn_valid()
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: c1cc1552616d ("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>
Diffstat (limited to 'arch/powerpc/include/asm/code-patching-asm.h')
0 files changed, 0 insertions, 0 deletions
