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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <4ad1b8cb7cd54c57e74e877235f64b5be5bbbe8f.1699025537.git.tanyuan@tinylab.org>
Date:   Sat,  4 Nov 2023 00:04:10 +0800
From:   Yuan Tan <tanyuan@...ylab.org>
To:     falcon@...ylab.org, arnd@...db.de, linux-kernel@...r.kernel.org,
        linux-mips@...r.kernel.org, linux-riscv@...ts.infradead.org,
        luc.vanoostenryck@...il.com, linux-sparse@...r.kernel.org
Cc:     linux@...ssschuh.net, palmer@...osinc.com,
        paul.walmsley@...ive.com, paulburton@...nel.org,
        paulmck@...nel.org, tim.bird@...y.com, tsbogend@...ha.franken.de,
        w@....eu, tanyuan@...ylab.org, i@...kray.me
Subject: [PATCH v1 13/14] DCE/DSE: add SECTION_NO_KEEP_SUPPORT option

It is able to drop the brute KEEP() keyword for some sections, when the
sections are able to link or group together with one of the used
sections.

Some syscalls are actually orphan sections.
SECTION_SHF_LINK_ORDER_SUPPORT or SECTION_SHF_GROUP_SUPPORT creates
references for these sections, eliminating the need for the KEEP()
directive.

Signed-off-by: Yuan Tan <tanyuan@...ylab.org>
Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
---
 include/asm-generic/vmlinux.lds.h | 24 ++++++++++++++++++------
 init/Kconfig                      |  9 +++++++++
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index ea8170e11ab1..f10afc42a1ac 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -201,18 +201,30 @@
 # endif
 #endif
 
-#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+#ifdef CONFIG_SECTION_NO_KEEP_SUPPORT
+#define NO_KEEP(sec) sec
+#else
+#define NO_KEEP(sec) KEEP(sec)
+#endif
+
+#define _BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _KEEP_, ...)	\
 	_BEGIN_##_label_ = .;						\
-	KEEP(*(BSEC_MAIN(_sec_)))					\
+	_KEEP_(*(BSEC_MAIN(_sec_)))					\
 	_END_##_label_ = .;
 
-#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, ...)		\
+	_BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, ##__VA_ARGS__, KEEP)
+
+#define _BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _KEEP_, ...)\
 	_label_##_BEGIN_ = .;						\
-	KEEP(*(BSEC_MAIN(_sec_)))					\
+	_KEEP_(*(BSEC_MAIN(_sec_)))					\
 	_label_##_END_ = .;
 
-#define BOUNDED_SECTION_BY(_sec_, _label_)				\
-	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
+#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, ...)		\
+	_BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, ##__VA_ARGS__, KEEP)
+
+#define BOUNDED_SECTION_BY(_sec_, _label_, ...)				\
+	_BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop, ##__VA_ARGS__, KEEP)
 
 #define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
 
diff --git a/init/Kconfig b/init/Kconfig
index 9599d2de44e8..aeb859e410b2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1467,6 +1467,13 @@ config HAVE_SECTION_NO_KEEP_SUPPORT
 	depends on HAVE_SECTION_SHF_LINK_ORDER_SUPPORT || HAVE_SECTION_SHF_GROUP_SUPPORT
 	default y
 
+config SECTION_NO_KEEP_SUPPORT
+	bool
+	depends on SECTION_SHF_LINK_ORDER_SUPPORT || SECTION_SHF_GROUP_SUPPORT
+	default y
+	help
+	  This option allows some sections unkept so they can be GC
+
 config HAVE_SECTION_SHF_LINK_ORDER_SUPPORT
 	bool
 	depends on AS_IS_GNU && AS_VERSION >= 23500
@@ -1765,6 +1772,7 @@ config RESTRICTED_TRIM_UNUSED_SYSCALLS
 config SECTION_SHF_LINK_ORDER_SUPPORT
 	bool "Using SHF_LINK_ORDER attribute (EXPERIMENTAL)" if EXPERT
 	depends on HAVE_SECTION_SHF_LINK_ORDER_SUPPORT
+	select SECTION_NO_KEEP_SUPPORT
 	help
 	  Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table
 	  like sections in kernel space.
@@ -1778,6 +1786,7 @@ config SECTION_SHF_LINK_ORDER_SUPPORT
 config SECTION_SHF_GROUP_SUPPORT
 	bool "Using SHF_GROUP attribute (EXPERIMENTAL)" if EXPERT
 	depends on HAVE_SECTION_SHF_GROUP_SUPPORT
+	select SECTION_NO_KEEP_SUPPORT
 	help
 	  Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table
 	  like sections in kernel space.
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ