Commit Graph

2 Commits

Author SHA1 Message Date
Samuel Thibault
92777f34df hurd: Fix PTR_{,DE}MANGLE calls
* libio/iofopncook.c (_IO_cookie_read, _IO_cookie_write,
	_IO_cookie_seek, _IO_cookie_close, _IO_old_cookie_seek)
	[!PTR_DEMANGLE]: Do not call PTR_DEMANGLE.
	(set_callbacks) [!PTR_MANGLE]: Do not call PTR_MANGLE.
	* libio/vtables.c (_IO_vtable_check)
	[!PTR_DEMANGLE]: Do not call PTR_DEMANGLE.
	* libio/libioP.h (IO_set_accept_foreign_vtables)
	[!PTR_MANGLE]: Do not call PTR_MANGLE.
2016-07-06 11:48:56 +02:00
Florian Weimer
db3476aff1 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.
2016-06-23 20:01:52 +02:00