]> git.baikalelectronics.ru Git - kernel.git/commit
RISC-V: Fix FIXMAP area corruption on RV32 systems
authorAnup Patel <Anup.Patel@wdc.com>
Mon, 19 Aug 2019 05:14:23 +0000 (05:14 +0000)
committerPaul Walmsley <paul.walmsley@sifive.com>
Wed, 28 Aug 2019 22:30:12 +0000 (15:30 -0700)
commite5b198c1caac03eee61b04b07fc4c84116a07664
tree27853a7d2a38418ae1a5ca80a43fc37de9869dc8
parent105f9378765ab89e50c53551fccbfca94afcdfa2
RISC-V: Fix FIXMAP area corruption on RV32 systems

Currently, various virtual memory areas of Linux RISC-V are organized
in increasing order of their virtual addresses is as follows:
1. User space area (This is lowest area and starts at 0x0)
2. FIXMAP area
3. VMALLOC area
4. Kernel area (This is highest area and starts at PAGE_OFFSET)

The maximum size of user space aread is represented by TASK_SIZE.

On RV32 systems, TASK_SIZE is defined as VMALLOC_START which causes the
user space area to overlap the FIXMAP area. This allows user space apps
to potentially corrupt the FIXMAP area and kernel OF APIs will crash
whenever they access corrupted FDT in the FIXMAP area.

On RV64 systems, TASK_SIZE is set to fixed 256GB and no other areas
happen to overlap so we don't see any FIXMAP area corruptions.

This patch fixes FIXMAP area corruption on RV32 systems by setting
TASK_SIZE to FIXADDR_START. We also move FIXADDR_TOP, FIXADDR_SIZE,
and FIXADDR_START defines to asm/pgtable.h so that we can avoid cyclic
header includes.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Tested-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
arch/riscv/include/asm/fixmap.h
arch/riscv/include/asm/pgtable.h