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>] [day] [month] [year] [list]
Message-ID: <SY4P282MB108446E9ED9FB180AE717D5F9DAD9@SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM>
Date:   Wed,  1 Mar 2023 14:22:32 +0800
From:   Tianyi Liu <i.pear@...look.com>
To:     arnd@...db.de
Cc:     hjl.tools@...il.com, linux-arch@...r.kernel.org,
        linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
        Tianyi Liu <i.pear@...look.com>
Subject: [PATCH] Discard .note.gnu.property in vmlinux

When the kernel image is finally linked, all the notes are packed into a
single .notes section, but these notes may have different alignments.

binutils above 2.32 adds a ".note.gnu.property" section to the compiled
output, which is 4-byte aligned on 32-bit, but 8-byte aligned on 64-bit.
At present, the notes generated by both the ELFNOTE macro and the VDSO
linker script are 4-byte aligned. So in a 64-bit kernel, packing segments
with different alignments will cause LibElf and tools like readelf to
crush or to read wrong values [1][2].

This patch discards ".note.gnu.property" from vmlinux.

Note that H.J. Lu has submitted a similar patch in the past[3],
but it was not merged.

[1] https://lore.kernel.org/bpf/57830c30-cd77-40cf-9cd1-3bb608aa602e@app.fastmail.com/
[2] https://lore.kernel.org/linux-arm-kernel/20210428172847.GC4022@arm.com/
[3] https://lore.kernel.org/lkml/20180924201459.35923-1-hjl.tools@gmail.com/

Signed-off-by: Tianyi Liu <i.pear@...look.com>
---
 include/asm-generic/vmlinux.lds.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index d1f57e4868ed..6db0f664c7d6 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -891,9 +891,13 @@
 /*
  * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler.
  * Otherwise, the type of .notes section would become PROGBITS instead of NOTES.
+ *
+ * Discard .note.gnu.property, which is 8-byte aligned and emitted by the
+ * compiler. Otherwise, the .notes section will be 8-byte aligned and other
+ * notes cannot be read.
  */
 #define NOTES								\
-	/DISCARD/ : { *(.note.GNU-stack) }				\
+	/DISCARD/ : { *(.note.GNU-stack) *(.note.gnu.property) }				\
 	.notes : AT(ADDR(.notes) - LOAD_OFFSET) {			\
 		BOUNDED_SECTION_BY(.note.*, _notes)			\
 	} NOTES_HEADERS							\
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ