mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/6] ARM: Map sections RO/XN
@ 2025-06-17 14:28 Sascha Hauer
  2025-06-17 14:28 ` [PATCH v2 1/6] ARM: pass barebox base to mmu_early_enable() Sascha Hauer
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Sascha Hauer @ 2025-06-17 14:28 UTC (permalink / raw)
  To: Ahmad Fatoum, BAREBOX

So far we mapped all RAM as read write with execute permission. This
series series hardens this a bit. The barebox text segment will be
mapped readonly with execute permission, the RO data section as readonly
without execute permission and the remaining RAM will lose its execute
permission.

I tested this series on ARMv5, ARMv7 and ARMv8. I am not confident
though that there are no regressions, so this new behaviour is behind a
Kconfig option. It is default-y, but can be disabled for debugging
purposses.  Once this series has proven stable it can be removed.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Changes in v2:
- Tested and fixed for ARMv5
- merge create_pages() and create_sections() into one functions (ahmad)
- introduce function to create mapping flags based on CONFIG_ARM_MMU_PERMISSIONS
- Link to v1: https://lore.barebox.org/20250606-mmu-xn-ro-v1-0-7ee6ddd134d4@pengutronix.de

---
Sascha Hauer (6):
      ARM: pass barebox base to mmu_early_enable()
      ARM: mmu: move ARCH_MAP_WRITECOMBINE to header
      ARM: MMU: map memory for barebox proper pagewise
      ARM: MMU: map text segment ro and data segments execute never
      ARM: MMU64: map memory for barebox proper pagewise
      ARM: MMU64: map text segment ro and data segments execute never

 arch/arm/Kconfig                 | 12 ++++++
 arch/arm/cpu/lowlevel_32.S       |  1 +
 arch/arm/cpu/mmu-common.h        | 20 +++++++++
 arch/arm/cpu/mmu_32.c            | 89 ++++++++++++++++++++++++++++++++--------
 arch/arm/cpu/mmu_64.c            | 82 +++++++++++++++++++++++++++---------
 arch/arm/cpu/uncompress.c        |  9 ++--
 arch/arm/include/asm/mmu.h       |  2 +-
 arch/arm/include/asm/pgtable64.h |  1 +
 arch/arm/lib32/barebox.lds.S     |  3 +-
 arch/arm/lib64/barebox.lds.S     |  5 ++-
 common/memory.c                  |  7 +++-
 include/mmu.h                    |  1 +
 12 files changed, 186 insertions(+), 46 deletions(-)
---
base-commit: 2ae2aa65792b5634e1e9b682fa7ef649569800d4
change-id: 20250606-mmu-xn-ro-e2a4c4b080a4

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-17 17:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-17 14:28 [PATCH v2 0/6] ARM: Map sections RO/XN Sascha Hauer
2025-06-17 14:28 ` [PATCH v2 1/6] ARM: pass barebox base to mmu_early_enable() Sascha Hauer
2025-06-17 14:28 ` [PATCH v2 2/6] ARM: mmu: move ARCH_MAP_WRITECOMBINE to header Sascha Hauer
2025-06-17 14:28 ` [PATCH v2 3/6] ARM: MMU: map memory for barebox proper pagewise Sascha Hauer
2025-06-17 14:28 ` [PATCH v2 4/6] ARM: MMU: map text segment ro and data segments execute never Sascha Hauer
2025-06-17 14:28 ` [PATCH v2 5/6] ARM: MMU64: map memory for barebox proper pagewise Sascha Hauer
2025-06-17 14:28 ` [PATCH v2 6/6] ARM: MMU64: map text segment ro and data segments execute never Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox