Bug 215303 - Kernel should refuse to load an ELF binary with zero entry point address
Summary: Kernel should refuse to load an ELF binary with zero entry point address
Status: NEW
Alias: None
Product: Other
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: other_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-11 15:56 UTC by H.J. Lu
Modified: 2021-12-11 15:56 UTC (History)
0 users

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

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.

Note You need to log in before you can comment on or make changes to this bug.