diff options
author | Florian Weimer <fweimer@redhat.com> | 2016-06-23 20:01:40 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2016-06-23 20:01:52 +0200 |
commit | db3476aff19b75c4fdefbe65fcd5f0a90588ba51 (patch) | |
tree | 5cefd4971a0e6b5d5f9eacf6d3532c6aedc7b352 /libio/memstream.c | |
parent | 64ba17317dc9343f0958755ad04af71ec3da637b (diff) | |
download | glibc-db3476aff19b75c4fdefbe65fcd5f0a90588ba51.tar.gz glibc-db3476aff19b75c4fdefbe65fcd5f0a90588ba51.tar.xz glibc-db3476aff19b75c4fdefbe65fcd5f0a90588ba51.zip |
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.
Diffstat (limited to 'libio/memstream.c')
-rw-r--r-- | libio/memstream.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libio/memstream.c b/libio/memstream.c index 7fa5245e72..e20b9c2250 100644 --- a/libio/memstream.c +++ b/libio/memstream.c @@ -33,7 +33,7 @@ static int _IO_mem_sync (_IO_FILE* fp) __THROW; static void _IO_mem_finish (_IO_FILE* fp, int) __THROW; -static const struct _IO_jump_t _IO_mem_jumps = +static const struct _IO_jump_t _IO_mem_jumps libio_vtable = { JUMP_INIT_DUMMY, JUMP_INIT (finish, _IO_mem_finish), @@ -86,7 +86,7 @@ __open_memstream (char **bufloc, _IO_size_t *sizeloc) free (new_f); return NULL; } - _IO_init (&new_f->fp._sf._sbf._f, 0); + _IO_init_internal (&new_f->fp._sf._sbf._f, 0); _IO_JUMPS_FILE_plus (&new_f->fp._sf._sbf) = &_IO_mem_jumps; _IO_str_init_static_internal (&new_f->fp._sf, buf, _IO_BUFSIZ, buf); new_f->fp._sf._sbf._f._flags &= ~_IO_USER_BUF; |