Skip to contentSkip to conversation

mark tramp_pg_dir read-only

PATCH In review YaoJun 2 participants 2 messages May 29, 2018

Subsystems (2)
lore
Share & tools
lore

YaoJun

author
#0 lore raw

PATCH 1/1 mark tramp_pg_dir read-only

To prevent KSMA(Kernel Space Mirroring Attack), it's necessary to set tramp_pg_dir read-only after initialization.

---
 arch/arm64/mm/mmu.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/mm/mmu.c +3 -0
index 2dbb2c9f1ec1..964520e4e675 100644
@@ -551,6 +551,9 @@ static int __init map_entry_trampoline(void)
 	__create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, PAGE_SIZE,
 			     prot, pgd_pgtable_alloc, 0);
 
+	update_mapping_prot(__pa_symbol(tramp_pg_dir), (unsigned long)tramp_pg_dir,
+			    PGD_SIZE, PAGE_KERNEL_RO);
+
 	/* Map both the text and data into the kernel page table */
 	__set_fixmap(FIX_ENTRY_TRAMP_TEXT, pa_start, prot);
 	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
Signature · 1 line
2.17.0
reviewer
#1 lore raw

Hi,

For patches to arm64, please CC the arm64 maintainers, and the linux-arm-kernel mailing list.

Generally, please try to follow the guidance of
Documentation/process/submitting-patches.rst

e.g. you can use get_maintainer.pl to figure out who to Cc:

[mark@lakrids:~/src/linux]% ./scripts/get_maintainer.pl arch/arm64/mm/mmu.c
Catalin Marinas <[email protected]> (maintainer:ARM64 PORT (AARCH64 ARCHITECTURE),commit_signer:8/16=50%)
Will Deacon <[email protected]> (maintainer:ARM64 PORT (AARCH64 ARCHITECTURE),commit_signer:9/16=56%,authored:6/16=38%,added_lines:205/242=85%,removed_lines:142/157=90%) Ard Biesheuvel <[email protected]> (commit_signer:5/16=31%)
Marc Zyngier <[email protected]> (commit_signer:4/16=25%)
Dan Williams <[email protected]> (commit_signer:2/16=12%)
Kristina Martsenko <[email protected]> (authored:2/16=12%)
James Morse <[email protected]> (authored:2/16=12%)
Tobias Klauser <[email protected]> (authored:1/16=6%)
Steve Capper <[email protected]> (authored:1/16=6%)
[email protected] (moderated list:ARM64 PORT (AARCH64 ARCHITECTURE))
[email protected] (open list)

Thanks,
Mark.

Quoted 24 lines · YaoJun

To prevent KSMA(Kernel Space Mirroring Attack), it's necessary to set tramp_pg_dir read-only after initialization.

---
 arch/arm64/mm/mmu.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/mm/mmu.c +3 -0
index 2dbb2c9f1ec1..964520e4e675 100644
@@ -551,6 +551,9 @@ static int __init map_entry_trampoline(void)
 	__create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, PAGE_SIZE,
 			     prot, pgd_pgtable_alloc, 0);
 
+	update_mapping_prot(__pa_symbol(tramp_pg_dir), (unsigned long)tramp_pg_dir,
+			    PGD_SIZE, PAGE_KERNEL_RO);
+
 	/* Map both the text and data into the kernel page table */
 	__set_fixmap(FIX_ENTRY_TRAMP_TEXT, pa_start, prot);
 	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
Signature · 1 line
2.17.0