lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241122163139.GAZ0Cx63Ia9kgYgRIr@fat_crate.local>
Date: Fri, 22 Nov 2024 17:31:39 +0100
From: "Borislav Petkov (AMD)" <bp@...en8.de>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: x86-ml <x86@...nel.org>, lkml <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH] x86/boot: Get rid of linux/init.h include

Hi,

this is what I think we should do (just a first patch) to decouple the
decompressor from kernel proper headers namespace so that there's no
collisions and ugly ifdeffery when those kernel proper headers get shared.

And if we want to share things, we will use asm/shared/ to put such shared
definitions there.

Thoughts?

---

Get rid of the linux/init.h kernel proper namespace include and add
a KERNEL_PROPER_HEADER header guard to protect any future inclusions
into the decompressor.

Signed-off-by: Borislav Petkov (AMD) <bp@...en8.de>
---
 arch/x86/boot/compressed/error.h   | 2 --
 arch/x86/boot/compressed/head_32.S | 7 +++++--
 arch/x86/boot/compressed/head_64.S | 7 +++++--
 arch/x86/include/asm/init.h        | 2 +-
 include/linux/init.h               | 2 ++
 5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/x86/boot/compressed/error.h b/arch/x86/boot/compressed/error.h
index 31f9e080d61a..938f6f1f1589 100644
--- a/arch/x86/boot/compressed/error.h
+++ b/arch/x86/boot/compressed/error.h
@@ -2,8 +2,6 @@
 #ifndef BOOT_COMPRESSED_ERROR_H
 #define BOOT_COMPRESSED_ERROR_H
 
-#include <linux/compiler.h>
-
 void warn(const char *m);
 void error(char *m) __noreturn;
 void panic(const char *fmt, ...) __noreturn __cold;
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index 1cfe9802a42f..6d7728582215 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -24,7 +24,6 @@
  */
 	.text
 
-#include <linux/init.h>
 #include <linux/linkage.h>
 #include <asm/segment.h>
 #include <asm/page_types.h>
@@ -32,6 +31,10 @@
 #include <asm/asm-offsets.h>
 #include <asm/bootparam.h>
 
+#ifdef KERNEL_PROPER_HEADER
+#error Do not include kernel proper namespace headers
+#endif
+
 /*
  * These symbols needed to be marked as .hidden to prevent the BFD linker from
  * generating R_386_32 (rather than R_386_RELATIVE) relocations for them when
@@ -42,7 +45,7 @@
 	.hidden _ebss
 	.hidden _end
 
-	__HEAD
+	.section ".head.text","ax"
 SYM_FUNC_START(startup_32)
 	cld
 	cli
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 1dcb794c5479..75ea0c8e4116 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -25,7 +25,6 @@
 	.code32
 	.text
 
-#include <linux/init.h>
 #include <linux/linkage.h>
 #include <asm/segment.h>
 #include <asm/boot.h>
@@ -37,6 +36,10 @@
 #include <asm/trapnr.h>
 #include "pgtable.h"
 
+#ifdef KERNEL_PROPER_HEADER
+#error Do not include kernel proper namespace headers
+#endif
+
 /*
  * Fix alignment at 16 bytes. Following CONFIG_FUNCTION_ALIGNMENT will result
  * in assembly errors due to trying to move .org backward due to the excessive
@@ -52,7 +55,7 @@
 	.hidden _ebss
 	.hidden _end
 
-	__HEAD
+	.section ".head.text","ax"
 
 /*
  * This macro gives the relative virtual address of X, i.e. the offset of X
diff --git a/arch/x86/include/asm/init.h b/arch/x86/include/asm/init.h
index 14d72727d7ee..6c47c84a3731 100644
--- a/arch/x86/include/asm/init.h
+++ b/arch/x86/include/asm/init.h
@@ -2,7 +2,7 @@
 #ifndef _ASM_X86_INIT_H
 #define _ASM_X86_INIT_H
 
-#define __head	__section(".head.text")
+#define __head __section(".head.text")
 
 struct x86_mapping_info {
 	void *(*alloc_pgt_page)(void *); /* allocate buf for page table */
diff --git a/include/linux/init.h b/include/linux/init.h
index ee1309473bc6..21e636abf3c4 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -2,6 +2,8 @@
 #ifndef _LINUX_INIT_H
 #define _LINUX_INIT_H
 
+#define KERNEL_PROPER_HEADER
+
 #include <linux/build_bug.h>
 #include <linux/compiler.h>
 #include <linux/stringify.h>
-- 
2.43.0


-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ