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. --- stdlib/strfmon_l.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stdlib') diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c index 5851a5b94a..39b51c017b 100644 --- a/stdlib/strfmon_l.c +++ b/stdlib/strfmon_l.c @@ -512,7 +512,7 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, #ifdef _IO_MTSAFE_IO f._sbf._f._lock = NULL; #endif - _IO_init (&f._sbf._f, 0); + _IO_init_internal (&f._sbf._f, 0); _IO_JUMPS (&f._sbf) = &_IO_str_jumps; _IO_str_init_static_internal (&f, dest, (s + maxsize) - dest, dest); /* We clear the last available byte so we can find out whether -- cgit 1.4.1