about summary refs log tree commit diff
path: root/sysdeps/ia64
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-02-25 12:10:57 +0100
committerFlorian Weimer <fweimer@redhat.com>2021-02-25 12:13:02 +0100
commit035c012e32c11e84d64905efaf55e74f704d3668 (patch)
tree7b08a9e9cbd8e4dd2e420cd6b7c204aeb5d61ccc /sysdeps/ia64
parenta79328c745219dcb395070cdcd3be065a8347f24 (diff)
downloadglibc-035c012e32c11e84d64905efaf55e74f704d3668.tar.gz
glibc-035c012e32c11e84d64905efaf55e74f704d3668.tar.xz
glibc-035c012e32c11e84d64905efaf55e74f704d3668.zip
Reduce the statically linked startup code [BZ #23323]
It turns out the startup code in csu/elf-init.c has a perfect pair of
ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, "return-to-csu: A
New Method to Bypass 64-bit Linux ASLR").  These functions are not
needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
are already processed by the dynamic linker.  However, the dynamic
linker skipped the main program for some reason.  For maximum
backwards compatibility, this is not changed, and instead, the main
map is consulted from __libc_start_main if the init function argument
is a NULL pointer.

For statically linked binaries, the old approach based on linker
symbols is still used because there is nothing else available.

A new symbol version __libc_start_main@@GLIBC_2.34 is introduced because
new binaries running on an old libc would not run their ELF
constructors, leading to difficult-to-debug issues.
Diffstat (limited to 'sysdeps/ia64')
-rw-r--r--sysdeps/ia64/dl-lookupcfg.h2
-rw-r--r--sysdeps/ia64/start.S9
2 files changed, 3 insertions, 8 deletions
diff --git a/sysdeps/ia64/dl-lookupcfg.h b/sysdeps/ia64/dl-lookupcfg.h
index 209d926bad..58ca32424b 100644
--- a/sysdeps/ia64/dl-lookupcfg.h
+++ b/sysdeps/ia64/dl-lookupcfg.h
@@ -50,7 +50,7 @@ extern void attribute_hidden _dl_unmap (struct link_map *map);
 {							\
   ElfW(Addr) addr;					\
   DL_DT_FUNCTION_ADDRESS(map, start, , addr)		\
-  init_t init = (init_t) addr; 				\
+  dl_init_t init = (dl_init_t) addr; 			\
   init (argc, argv, env);				\
 }
 
diff --git a/sysdeps/ia64/start.S b/sysdeps/ia64/start.S
index 0018acc821..b28f8cb429 100644
--- a/sysdeps/ia64/start.S
+++ b/sysdeps/ia64/start.S
@@ -82,20 +82,15 @@ _start:
 	{
 	  addl r11 = @ltoff(__libc_ia64_register_backing_store_base), gp
 	  addl out0 = @ltoff(@fptr(main)), gp
-	  addl out3 = @ltoff(@fptr(__libc_csu_init)), gp
+	  mov out3 = r0		/* Used to be init.  */
 	  ;;
 	}
 	{ .mmi
 	  ld8 r3 = [r11]	/* pointer to __libc_ia64_register_backing_store_base */
 	  ld8 out0 = [out0]	/* pointer to `main' function descriptor */
-	  addl out4 = @ltoff(@fptr(__libc_csu_fini)), gp
+	  mov out4 = r0		/* Used to be fini.  */
 	  ;;
 	}
-	{ .mmi
-	  ld8 out3 = [out3]	/* pointer to `init' function descriptor */
-	  ld8 out4 = [out4]	/* pointer to `fini' function descriptor */
-	  nop 0
-	}
 	.body
 	{ .mib
 	  st8 [r3] = r10