libio: Implement vtable verification [BZ #20191]
commitdb3476aff19b75c4fdefbe65fcd5f0a90588ba51
authorFlorian Weimer <fweimer@redhat.com>
Thu, 23 Jun 2016 18:01:40 +0000 (23 20:01 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 23 Jun 2016 18:01:52 +0000 (23 20:01 +0200)
tree5cefd4971a0e6b5d5f9eacf6d3532c6aedc7b352
parent64ba17317dc9343f0958755ad04af71ec3da637b
libio: Implement vtable verification [BZ #20191]

This commit puts all libio vtables in a dedicated, read-only ELF
section, so that they are consecutive in memory.  Before any indirect
jump, the vtable pointer is checked against the section boundaries,
and the process is terminated if the vtable pointer does not fall into
the special ELF section.

To enable backwards compatibility, a special flag variable
(_IO_accept_foreign_vtables), protected by the pointer guard, avoids
process termination if libio stream object constructor functions have
been called earlier.  Such constructor functions are called by the GCC
2.95 libstdc++ library, and this mechanism ensures compatibility with
old binaries.  Existing callers inside glibc of these functions are
adjusted to call the original functions, not the wrappers which enable
vtable compatiblity.

The compatibility mechanism is used to enable passing FILE * objects
across a static dlopen boundary, too.
30 files changed:
ChangeLog
Makerules
debug/obprintf_chk.c
debug/vdprintf_chk.c
debug/vsnprintf_chk.c
debug/vsprintf_chk.c
libio/Makefile
libio/fileops.c
libio/genops.c
libio/iofdopen.c
libio/iofopen.c
libio/iofopncook.c
libio/iopopen.c
libio/iovdprintf.c
libio/libioP.h
libio/memstream.c
libio/obprintf.c
libio/oldfileops.c
libio/oldiofdopen.c
libio/oldiofopen.c
libio/oldiopopen.c
libio/strops.c
libio/vsnprintf.c
libio/vswprintf.c
libio/vtables.c [new file with mode: 0644]
libio/wfileops.c
libio/wmemstream.c
libio/wstrops.c
stdio-common/vfprintf.c
stdlib/strfmon_l.c