diff mbox series

[11/12] powerpc: Check prom_init for disallowed sections

Message ID 20181015025000.4522-11-benh@kernel.crashing.org (mailing list archive)
State Accepted
Commit 2c51d97ee88da897db8405f659d1735ffe86ad7c
Headers show
Series [01/12] powerpc/prom_init: Make of_workarounds static | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning next/apply_patch Patch failed to apply
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Benjamin Herrenschmidt Oct. 15, 2018, 2:49 a.m. UTC
prom_init.c must not modify the kernel image outside
of the .bss.prominit section. Thus make sure that
prom_init.o doesn't have anything in any of these:

	.data
	.bss
	.init.data

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/kernel/prom_init_check.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Michael Ellerman Oct. 19, 2018, 2:51 a.m. UTC | #1
On Mon, 2018-10-15 at 02:49:59 UTC, Benjamin Herrenschmidt wrote:
> prom_init.c must not modify the kernel image outside
> of the .bss.prominit section. Thus make sure that
> prom_init.o doesn't have anything in any of these:
> 
> 	.data
> 	.bss
> 	.init.data
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/2c51d97ee88da897db8405f659d173

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index acb6b9226352..667df97d2595 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -28,6 +28,18 @@  OBJ="$2"
 
 ERROR=0
 
+function check_section()
+{
+    file=$1
+    section=$2
+    size=$(objdump -h -j $section $file 2>/dev/null | awk "\$2 == \"$section\" {print \$3}")
+    size=${size:-0}
+    if [ $size -ne 0 ]; then
+	ERROR=1
+	echo "Error: Section $section not empty in prom_init.c" >&2
+    fi
+}
+
 for UNDEF in $($NM -u $OBJ | awk '{print $2}')
 do
 	# On 64-bit nm gives us the function descriptors, which have
@@ -66,4 +78,8 @@  do
 	fi
 done
 
+check_section $OBJ .data
+check_section $OBJ .bss
+check_section $OBJ .init.data
+
 exit $ERROR