00db10
commit c259196b5005812aa3294dbf4eeca29b266a4522
00db10
Author: Florian Weimer <fweimer@redhat.com>
00db10
Date:   Fri Mar 1 18:53:03 2019 +0100
00db10
00db10
    elf/tst-big-note: Improve accuracy of test [BZ #20419]
00db10
    
00db10
    It is possible that the link editor injects an allocated ABI tag note
00db10
    before the artificial, allocated large note in the test.  Note parsing
00db10
    in open_verify stops when the first ABI tag note is encountered, so if
00db10
    the ABI tag note comes first, the problematic code is not actually
00db10
    exercised.
00db10
    
00db10
    Also tweak the artificial note so that it is a syntactically valid
00db10
    4-byte aligned note, in case the link editor tries to parse notes and
00db10
    process them.
00db10
    
00db10
    Improves the testing part of commit 0065aaaaae51cd60210ec3a7e13.
00db10
    
00db10
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
00db10
00db10
(Minor adjustment for Makefile conflict.)
00db10
00db10
diff --git a/elf/Makefile b/elf/Makefile
00db10
index b46b3a0e3542a06f..2b2662d5cf96c437 100644
00db10
--- a/elf/Makefile
00db10
+++ b/elf/Makefile
00db10
@@ -244,8 +244,8 @@ extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
00db10
 # We need this variable to be sure the test modules get the right CPPFLAGS.
00db10
 test-extras += $(modules-names)
00db10
 
00db10
-# filtmod1.so has a special rule
00db10
-modules-names-nobuild := filtmod1
00db10
+# filtmod1.so, tst-big-note-lib.so have special rules.
00db10
+modules-names-nobuild := filtmod1 tst-big-note-lib
00db10
 
00db10
 ifneq (no,$(multi-arch))
00db10
 tests-static += ifuncmain1static ifuncmain1picstatic \
00db10
@@ -1239,3 +1239,8 @@ $(objpfx)tst-audit12mod1.so: $(objpfx)tst-audit12mod2.so
00db10
 LDFLAGS-tst-audit12mod2.so = -Wl,--version-script=tst-audit12mod2.map
00db10
 
00db10
 $(objpfx)tst-big-note: $(objpfx)tst-big-note-lib.so
00db10
+# Avoid creating an ABI tag note, which may come before the
00db10
+# artificial, large note in tst-big-note-lib.o and invalidate the
00db10
+# test.
00db10
+$(objpfx)tst-big-note-lib.so: $(objpfx)tst-big-note-lib.o
00db10
+	$(LINK.o) -shared -o $@ $(LDFLAGS.so) $<
00db10
diff --git a/elf/tst-big-note-lib.S b/elf/tst-big-note-lib.S
00db10
index 6b514a03cc686141..c97590ccb05e9b2e 100644
00db10
--- a/elf/tst-big-note-lib.S
00db10
+++ b/elf/tst-big-note-lib.S
00db10
@@ -20,7 +20,13 @@
00db10
    On a typical Linux system with 8MiB "ulimit -s", that was enough
00db10
    to trigger stack overflow in open_verify.  */
00db10
 
00db10
+#define NOTE_SIZE 8*1024*1024
00db10
+
00db10
 .pushsection .note.big,"a"
00db10
-.balign 4
00db10
-.fill 8*1024*1024, 1, 0
00db10
+	.balign 4
00db10
+	.long 5 		/* n_namesz.  Length of "GLIBC".  */
00db10
+	.long NOTE_SIZE		/* n_descsz.  */
00db10
+	.long 0			/* n_type.  */
00db10
+	.ascii "GLIBC\0\0\0"	/* Name and alignment to four bytes.  */
00db10
+	.fill NOTE_SIZE, 1, 0
00db10
 .popsection