riscv: Improve stack randomisation on RV64
authorKefeng Wang <wangkefeng.wang@huawei.com>
Thu, 12 Aug 2021 11:47:02 +0000 (19:47 +0800)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Sat, 11 Sep 2021 05:25:34 +0000 (22:25 -0700)
This enlarges the bits availiable for stack randomisation on RV64 from
the default of 8MiB to 1GiB, to match arm64 and x86.

Also, update the documentation to reflect our support for stack
randomisation.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
[Palmer: commit text]
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Documentation/features/vm/ELF-ASLR/arch-support.txt
arch/riscv/include/asm/elf.h

index 99cb6d7f50051cab495d937747f733eaece9730e..2949c99fbb2f9585ad8b51e26ad84dc3b87be196 100644 (file)
@@ -22,7 +22,7 @@
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
-    |       riscv: | TODO |
+    |       riscv: |  ok  |
     |        s390: |  ok  |
     |          sh: | TODO |
     |       sparc: | TODO |
index f4b490cd0e5d1b3b0b903ef960130bd5e17644ca..f53c40026c7aa08e0170d8d58b6873760fdfb87f 100644 (file)
@@ -42,6 +42,9 @@
  */
 #define ELF_ET_DYN_BASE                ((TASK_SIZE / 3) * 2)
 
+#ifdef CONFIG_64BIT
+#define STACK_RND_MASK         (0x3ffff >> (PAGE_SHIFT - 12))
+#endif
 /*
  * This yields a mask that user programs can use to figure out what
  * instruction set this CPU supports.  This could be done in user space,