Bug 215303

Summary: Kernel should refuse to load an ELF binary with zero entry point address
Product: Other Reporter: H.J. Lu (hjl.tools)
Component: OtherAssignee: other_other
Status: NEW ---    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:

Description H.J. Lu 2021-12-11 15:56:54 UTC
[hjl@gnu-cfl-2 entry-1]$ cat load.c
int foo;
[hjl@gnu-cfl-2 entry-1]$ make
gcc -O2 -fPIC   -c -o load.o load.c
gcc -shared -Wl,--entry=0 -O2 -o load.so load.o
readelf -h load.so
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          13832 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         10
  Size of section headers:           64 (bytes)
  Number of section headers:         27
  Section header string table index: 26
./load.so
make: *** [Makefile:7: all] Segmentation fault (core dumped)
[hjl@gnu-cfl-2 entry-1]$ 

According to gABI:

http://www.sco.com/developers/gabi/latest/ch4.eheader.html

e_entry

This member gives the virtual address to which the system first transfers
control, thus starting the process. If the file has no associated entry
point, this member holds zero.

Kernel ELF loader should refuse to load an ELF binary with zero entry
point address.