From db3476aff19b75c4fdefbe65fcd5f0a90588ba51 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 23 Jun 2016 20:01:40 +0200 Subject: 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. --- libio/oldiopopen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libio/oldiopopen.c') diff --git a/libio/oldiopopen.c b/libio/oldiopopen.c index ea75b4fb90..bce74b1a5b 100644 --- a/libio/oldiopopen.c +++ b/libio/oldiopopen.c @@ -211,7 +211,7 @@ _IO_old_popen (const char *command, const char *mode) fp = &new_f->fpx.file.file._file; _IO_old_init (fp, 0); _IO_JUMPS_FILE_plus (&new_f->fpx.file) = &_IO_old_proc_jumps; - _IO_old_file_init ((struct _IO_FILE_plus *) &new_f->fpx.file); + _IO_old_file_init_internal ((struct _IO_FILE_plus *) &new_f->fpx.file); #if !_IO_UNIFIED_JUMPTABLES new_f->fpx.file.vtable = NULL; #endif @@ -267,7 +267,7 @@ _IO_old_proc_close (_IO_FILE *fp) return wstatus; } -const struct _IO_jump_t _IO_old_proc_jumps = { +const struct _IO_jump_t _IO_old_proc_jumps libio_vtable = { JUMP_INIT_DUMMY, JUMP_INIT(finish, _IO_old_file_finish), JUMP_INIT(overflow, _IO_old_file_overflow), -- cgit 1.4.1