Patch "ARM: OMAP: Fix SRAM W+X mapping" has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
ARM: OMAP: Fix SRAM W+X mapping
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
arm-omap-fix-sram-w-x-mapping.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
eb85a355c3afd9379f5953cfe2df73632d14c884Mon Sep 17 00:00:00 2001
From: Tony Lindgren <[email protected]>
Date: Wed, 21 Mar 2018 08:16:29 -0700
Subject: ARM: OMAP: Fix SRAM W+X mapping
From: Tony Lindgren <[email protected]>
commit eb85a355c3afd9379f5953cfe2df73632d14c884 upstream.
We are still using custom SRAM code for some SoCs and are not marking the PM code mapped to SRAM as read-only and executable after we're done. With CONFIG_DEBUG_WX=y, we will get "Found insecure W+X mapping at address" warning.
Let's fix this issue the same way as commit 728bbe75c82f ("misc: sram:
Introduce support code for protect-exec sram type") is doing for drivers/misc/sram-exec.c.
On omap3, we need to restore SRAM when returning from off mode after idle, so init time configuration is not enough.
And as we no longer have users for omap_sram_push_address() we can make it static while at it.
Note that eventually we should be using sram-exec.c for all SoCs.
--- arch/arm/plat-omap/include/plat/sram.h | 11 ---------- arch/arm/plat-omap/sram.c | 36 ++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 11 deletions(-)
arch/arm/plat-omap/include/plat/sram.h +1 -10
@@ -5,13 +5,4 @@ void omap_map_sram(unsigned long start, unsigned long skip, int cached);void omap_sram_reset (void ); -extern void *omap_sram_push_address (unsigned long size); - -/* Macro to push a function to the internal SRAM, using the fncpy API */ -#define omap_sram_push (funcp, size) ({ \ - typeof(&(funcp)) _res = NULL; \ - void *_sram_address = omap_sram_push_address(size); \ - if (_sram_address) \ - _res = fncpy(_sram_address, &(funcp), size); \ - _res; \ -}) +extern void *omap_sram_push (void *funcp,unsigned long size);
arch/arm/plat-omap/sram.c +35 -1
@@ -23,6 +23,7 @@#include <asm/fncpy.h> #include <asm/tlb.h> #include <asm/cacheflush.h> +#include <asm/set_memory.h> #include <asm/mach/map.h>
@@ -42,7 +43,7 @@ static void __iomem *omap_sram_ceil;* Note that fncpy requires the returned address to be aligned * to an 8-byte boundary. */ -void *omap_sram_push_address (unsigned long size) +static void *omap_sram_push_address (unsigned long size) {unsigned long available, new_ceil = (unsigned long )omap_sram_ceil;
@@ -60,6 +61,30 @@ void *omap_sram_push_address(unsigned loreturn (void *)omap_sram_ceil; } +void *omap_sram_push (void *funcp,unsigned long size) +{ +void *sram; +unsigned long base; +int pages; +void *dst =NULL ; + + sram =omap_sram_push_address (size); +if (!sram) +return NULL ; + + base = (unsigned long )sram &PAGE_MASK ; + pages =PAGE_ALIGN (size) /PAGE_SIZE ; + +set_memory_rw (base, pages); + + dst =fncpy (sram, funcp, size); + +set_memory_ro (base, pages); +set_memory_x (base, pages); + +return dst; +} +/* * The SRAM context is lost during off-idle and stack * needs to be reset.
@@ -75,6 +100,9 @@ void omap_sram_reset(void)void __init omap_map_sram (unsigned long start,unsigned long size,unsigned long skip,int cached) { +unsigned long base; +int pages; +if (size ==0 )return ;
@@ -95,4 +123,10 @@ void __init omap_map_sram(unsigned long*/ memset_io (omap_sram_base + omap_sram_skip,0 , omap_sram_size - omap_sram_skip); + + base = (unsigned long )omap_sram_base; + pages =PAGE_ALIGN (omap_sram_size) /PAGE_SIZE ; + +set_memory_ro (base, pages); +set_memory_x (base, pages); }
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/arm-omap-fix-sram-w-x-mapping.patch