Drop ELF notes from non-EFI binary too
PATCH 1/1 Drop ELF notes from non-EFI binary too
The ELF is repacked from from 64bit to 32bit. With CET-related notes, which use 64bit fields, this results in 32bit binary with corrupted notes. Drop them all (except build-id and PVH note retained explicitly).
--- xen/arch/x86/xen.lds.S | 7 ------- 1 file changed, 7 deletions(-)
xen/arch/x86/xen.lds.S +0 -7
@@ -192,13 +192,6 @@ SECTIONS #endif #endif -#ifndef EFI - /* Retain these just for the purpose of possible analysis tools. */ - DECL_SECTION(.note) { - *(.note.*) - } PHDR(note) PHDR(text) -#endif - _erodata = .; . = ALIGN(SECTION_ALIGN);
Signature · 1 line
2.39.2
Quoted 6 lines · Marek Marczykowski-Górecki
The ELF is repacked from from 64bit to 32bit. With CET-related notes, which use 64bit fields, this results in 32bit binary with corrupted notes. Drop them all (except build-id and PVH note retained explicitly).
Suggested-by Jan Beulich <[email protected]>
Perhaps a misunderstanding: Yes, I did suggest this as a possibility, but I didn't really mean we actually do so. At the very least not without further clarifying what the cons of doing so are. The notes, after all, are actually valid in xen-syms; they become bogus in the course of mkelf32's processing.
Quoted 6 lines
xen/arch/x86/xen.lds.S +0
-0@@ -192,13 +192,6 @@ SECTIONS #endif #endif
xen/arch/x86/xen.lds.S SECTIONS · line 197
Quoted 10 lines
xen/arch/x86/xen.lds.S +0
-7-#ifndef EFI - /* Retain these just for the purpose of possible analysis tools. */ - DECL_SECTION(.note) { - *(.note.*) - } PHDR(note) PHDR(text) -#endif - _erodata = .; . = ALIGN(SECTION_ALIGN);
Is this sufficient? .note.* isn't part of DISCARD_SECTIONS except for xen.efi. I would expect it needs to move there from DISCARD_EFI_SECTIONS. Otherwise, aiui, the linker's orphan section placement will kick in. Yet at that point you'd also affect Arm and RISC-V (which, interestingly, don't place .note.* anywhere at all right now, afaics).
Jan
Quoted 29 lines · Jan Beulich
Quoted 6 lines · Marek Marczykowski-Górecki
The ELF is repacked from from 64bit to 32bit. With CET-related notes, which use 64bit fields, this results in 32bit binary with corrupted notes. Drop them all (except build-id and PVH note retained explicitly).
Suggested-by Jan Beulich <[email protected]>Perhaps a misunderstanding: Yes, I did suggest this as a possibility, but I didn't really mean we actually do so. At the very least not without further clarifying what the cons of doing so are. The notes, after all, are actually valid in xen-syms; they become bogus in the course of mkelf32's processing.
Quoted 15 lines
xen/arch/x86/xen.lds.S +0
-7@@ -192,13 +192,6 @@ SECTIONS #endif #endif -#ifndef EFI - /* Retain these just for the purpose of possible analysis tools. */ - DECL_SECTION(.note) { - *(.note.*) - } PHDR(note) PHDR(text) -#endif - _erodata = .;
Quoted 5 lines
xen/arch/x86/xen.lds.S SECTIONS · line 197
Quoted 1 line
xen/arch/x86/xen.lds.S +0
-0. = ALIGN(SECTION_ALIGN);Is this sufficient? .note.* isn't part of
DISCARD_SECTIONSexcept for xen.efi. I would expect it needs to move there fromDISCARD_EFI_SECTIONS. Otherwise, aiui, the linker's orphan section placement will kick in.
What supposedly happens then? By looking at binary produced with this patch, I don't see other .note sections included.
Quoted 3 lines
Yet
at that point you'd also affect Arm and RISC-V (which, interestingly, don't place .note.* anywhere at all right now, afaics).
That's interesting observation. For RISC-V, I'm not surprised given how fresh it is in tree, but if Arm doesn't need it either, maybe adding to DISCARD_SECTIONS isn't such a bad idea?
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Quoted 30 lines · Marek Marczykowski-Górecki
Quoted 29 lines · Jan Beulich
Quoted 6 lines · Marek Marczykowski-Górecki
The ELF is repacked from from 64bit to 32bit. With CET-related notes, which use 64bit fields, this results in 32bit binary with corrupted notes. Drop them all (except build-id and PVH note retained explicitly).
Suggested-by Jan Beulich <[email protected]>Perhaps a misunderstanding: Yes, I did suggest this as a possibility, but I didn't really mean we actually do so. At the very least not without further clarifying what the cons of doing so are. The notes, after all, are actually valid in xen-syms; they become bogus in the course of mkelf32's processing.
Quoted 15 lines
xen/arch/x86/xen.lds.S +0
-7@@ -192,13 +192,6 @@ SECTIONS #endif #endif -#ifndef EFI - /* Retain these just for the purpose of possible analysis tools. */ - DECL_SECTION(.note) { - *(.note.*) - } PHDR(note) PHDR(text) -#endif - _erodata = .;
Quoted 8 lines
Quoted 5 lines
xen/arch/x86/xen.lds.S SECTIONS · line 197
Quoted 1 line
xen/arch/x86/xen.lds.S +0
-0. = ALIGN(SECTION_ALIGN);Is this sufficient? .note.* isn't part of
DISCARD_SECTIONSexcept for xen.efi. I would expect it needs to move there fromDISCARD_EFI_SECTIONS. Otherwise, aiui, the linker's orphan section placement will kick in.What supposedly happens then? By looking at binary produced with this patch, I don't see other .note sections included.
The linker can't really discard them without being told so, from all I know. So the pieces must land somewhere, and considering the special section type (SHT_NOTE) I would find it odd if they were folded into some other section.
Quoted 7 lines
Quoted 3 lines
Yet
at that point you'd also affect Arm and RISC-V (which, interestingly, don't place .note.* anywhere at all right now, afaics).That's interesting observation. For RISC-V, I'm not surprised given how fresh it is in tree, but if Arm doesn't need it either, maybe adding to
DISCARD_SECTIONSisn't such a bad idea?
Well, yes, if we want to get rid of them, putting them there makes sense. First we need to figure where the notes end up when not placed explicitly (as that'll tell us whether on Arm they can be useful at all right now).
Jan