Skip to content

Commit

Permalink
powerpc/mm: Don't be too strict with _etext alignment on PPC32
Browse files Browse the repository at this point in the history
Similar to PPC64, accept to map RO data as ROX as a trade off between
between security and memory usage.

Having RO data executable is not a high risk as RO data can't be
modified to forge an exploit.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/8c4a0d89d944eed984dd941e509614031a5ace2b.1589866984.git.christophe.leroy@csgroup.eu
  • Loading branch information
Christophe Leroy authored and Michael Ellerman committed May 26, 2020
1 parent 0c8c2c9 commit a0591b6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
26 changes: 0 additions & 26 deletions arch/powerpc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -778,32 +778,6 @@ config THREAD_SHIFT
Used to define the stack size. The default is almost always what you
want. Only change this if you know what you are doing.

config ETEXT_SHIFT_BOOL
bool "Set custom etext alignment" if STRICT_KERNEL_RWX && \
(PPC_BOOK3S_32 || PPC_8xx)
depends on ADVANCED_OPTIONS
help
This option allows you to set the kernel end of text alignment. When
RAM is mapped by blocks, the alignment needs to fit the size and
number of possible blocks. The default should be OK for most configs.

Say N here unless you know what you are doing.

config ETEXT_SHIFT
int "_etext shift" if ETEXT_SHIFT_BOOL
range 17 28 if STRICT_KERNEL_RWX && PPC_BOOK3S_32
range 19 23 if STRICT_KERNEL_RWX && PPC_8xx
default 17 if STRICT_KERNEL_RWX && PPC_BOOK3S_32
default 19 if STRICT_KERNEL_RWX && PPC_8xx
default PPC_PAGE_SHIFT
help
On Book3S 32 (603+), IBATs are used to map kernel text.
Smaller is the alignment, greater is the number of necessary IBATs.

On 8xx, large pages (512kb or 8M) are used to map kernel linear
memory. Aligning to 8M reduces TLB misses as only 8M pages are used
in that case.

config DATA_SHIFT_BOOL
bool "Set custom data alignment" if STRICT_KERNEL_RWX && \
(PPC_BOOK3S_32 || PPC_8xx)
Expand Down
3 changes: 1 addition & 2 deletions arch/powerpc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <asm/thread_info.h>

#define STRICT_ALIGN_SIZE (1 << CONFIG_DATA_SHIFT)
#define ETEXT_ALIGN_SIZE (1 << CONFIG_ETEXT_SHIFT)

ENTRY(_stext)

Expand Down Expand Up @@ -116,7 +115,7 @@ SECTIONS

} :text

. = ALIGN(ETEXT_ALIGN_SIZE);
. = ALIGN(PAGE_SIZE);
_etext = .;
PROVIDE32 (etext = .);

Expand Down

0 comments on commit a0591b6

Please sign in to comment.