.. | .. |
---|
78 | 78 | EXPORT_SYMBOL(elf_set_personality); |
---|
79 | 79 | |
---|
80 | 80 | /* |
---|
81 | | - * Set READ_IMPLIES_EXEC if: |
---|
82 | | - * - the binary requires an executable stack |
---|
83 | | - * - we're running on a CPU which doesn't support NX. |
---|
| 81 | + * An executable for which elf_read_implies_exec() returns TRUE will |
---|
| 82 | + * have the READ_IMPLIES_EXEC personality flag set automatically. |
---|
| 83 | + * |
---|
| 84 | + * The decision process for determining the results are: |
---|
| 85 | + * |
---|
| 86 | + * CPU: | lacks NX* | has NX | |
---|
| 87 | + * ELF: | | | |
---|
| 88 | + * ---------------------|------------|------------| |
---|
| 89 | + * missing PT_GNU_STACK | exec-all | exec-all | |
---|
| 90 | + * PT_GNU_STACK == RWX | exec-all | exec-stack | |
---|
| 91 | + * PT_GNU_STACK == RW | exec-all | exec-none | |
---|
| 92 | + * |
---|
| 93 | + * exec-all : all PROT_READ user mappings are executable, except when |
---|
| 94 | + * backed by files on a noexec-filesystem. |
---|
| 95 | + * exec-none : only PROT_EXEC user mappings are executable. |
---|
| 96 | + * exec-stack: only the stack and PROT_EXEC user mappings are executable. |
---|
| 97 | + * |
---|
| 98 | + * *this column has no architectural effect: NX markings are ignored by |
---|
| 99 | + * hardware, but may have behavioral effects when "wants X" collides with |
---|
| 100 | + * "cannot be X" constraints in memory permission flags, as in |
---|
| 101 | + * https://lkml.kernel.org/r/20190418055759.GA3155@mellanox.com |
---|
| 102 | + * |
---|
84 | 103 | */ |
---|
85 | 104 | int arm_elf_read_implies_exec(int executable_stack) |
---|
86 | 105 | { |
---|
87 | | - if (executable_stack != EXSTACK_DISABLE_X) |
---|
| 106 | + if (executable_stack == EXSTACK_DEFAULT) |
---|
88 | 107 | return 1; |
---|
89 | 108 | if (cpu_architecture() < CPU_ARCH_ARMv6) |
---|
90 | 109 | return 1; |
---|