This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] elf/tst-big-note: Improve accuracy of test [BZ #20419]


It is possible that the link editor injects an allocated ABI tag note
before the artificial, allocated large note in the test.  Note parsing
in open_verify stops when the first ABI tag note is encountered, so if
the ABI tag note comes first, the problematic code is not actually
exercised.

Also tweak the artificial note so that it is a syntactically valid
4-byte aligned note, in case the link editor tries to parse notes and
process them.

Improves the testing part of commit 0065aaaaae51cd60210ec3a7e13.

Tested on ppc64le, including that the test now crashes as expected on a
glibc-2.17-derived glibc without the backport of the original fix.

2019-03-01  Florian Weimer  <fweimer@redhat.com>

	[BZ #20419]
	* elf/tst-big-note-lib.S: Create a syntactically valid note.
	* elf/Makefile (tst-big-note-lib.so): Do not link with startup
	code, to avoid creating an ABI tag note.

diff --git a/elf/Makefile b/elf/Makefile
index 55204073a3..cc48b5d273 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -1515,6 +1515,11 @@ tst-libc_dlvsym-static-ENV = \
 $(objpfx)tst-libc_dlvsym-static.out: $(objpfx)tst-libc_dlvsym-dso.so
 
 $(objpfx)tst-big-note: $(objpfx)tst-big-note-lib.so
+# Avoid creating an ABI tag note, which may come before the
+# artificial, large note in tst-big-note-lib.o and invalidate the
+# test.
+$(objpfx)tst-big-note-lib.so: $(objpfx)tst-big-note-lib.o
+	$(LINK.o) -shared -o $@ $(LDFLAGS.so) $<
 
 $(objpfx)tst-unwind-ctor: $(objpfx)tst-unwind-ctor-lib.so
 
diff --git a/elf/tst-big-note-lib.S b/elf/tst-big-note-lib.S
index e2008cf4ae..721686fa0e 100644
--- a/elf/tst-big-note-lib.S
+++ b/elf/tst-big-note-lib.S
@@ -20,7 +20,13 @@
    On a typical Linux system with 8MiB "ulimit -s", that was enough
    to trigger stack overflow in open_verify.  */
 
+#define NOTE_SIZE 8*1024*1024
+
 .pushsection .note.big,"a"
-.balign 4
-.fill 8*1024*1024, 1, 0
+	.balign 4
+	.long 5 		/* n_namesz.  Length of "GLIBC".  */
+	.long NOTE_SIZE		/* n_descsz.  */
+	.long 0			/* n_type.  */
+	.ascii "GLIBC\0\0\0"	/* Name and alignment to four bytes.  */
+	.fill NOTE_SIZE, 1, 0
 .popsection


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]