|author||Ard Biesheuvel <firstname.lastname@example.org>||2018-11-07 11:36:20 +0100|
|committer||Will Deacon <email@example.com>||2018-11-20 11:38:26 +0000|
|parent||arm64: mm: purge lazily unmapped vm regions before changing permissions (diff)|
arm64: mm: apply r/o permissions of VM areas to its linear alias as well
On arm64, we use block mappings and contiguous hints to map the linear region, to minimize the TLB footprint. However, this means that the entire region is mapped using read/write permissions, which we cannot modify at page granularity without having to take intrusive measures to prevent TLB conflicts. This means the linear aliases of pages belonging to read-only mappings (executable or otherwise) in the vmalloc region are also mapped read/write, and could potentially be abused to modify things like module code, bpf JIT code or other read-only data. So let's fix this, by extending the set_memory_ro/rw routines to take the linear alias into account. The consequence of enabling this is that we can no longer use block mappings or contiguous hints, so in cases where the TLB footprint of the linear region is a bottleneck, performance may be affected. Therefore, allow this feature to be runtime en/disabled, by setting rodata=full (or 'on' to disable just this enhancement, or 'off' to disable read-only mappings for code and r/o data entirely) on the kernel command line. Also, allow the default value to be set via a Kconfig option. Tested-by: Laura Abbott <firstname.lastname@example.org> Signed-off-by: Ard Biesheuvel <email@example.com> Signed-off-by: Will Deacon <firstname.lastname@example.org>
Diffstat (limited to '')
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 787d7850e064..bf57c48c77df 100644
@@ -958,6 +958,20 @@ config ARM64_SSBD
If unsure, say Y.
+ bool "Apply r/o permissions of VM areas also to their linear aliases"
+ default y
+ Apply read-only attributes of VM areas to the linear alias of
+ the backing pages as well. This prevents code or read-only data
+ from being modified (inadvertently or intentionally) via another
+ mapping of the same memory page. This additional enhancement can
+ be turned off at runtime by passing rodata=[off|on] (and turned on
+ with rodata=full if this option is set to 'n')
+ This requires the linear region to be mapped down to pages,
+ which may adversely affect performance in some cases.
bool "Emulate deprecated/obsolete ARMv8 instructions"
depends on COMPAT