aboutsummaryrefslogtreecommitdiff
path: root/debug
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-06-23 20:01:40 +0200
committerFlorian Weimer <fweimer@redhat.com>2016-06-23 20:01:52 +0200
commitdb3476aff19b75c4fdefbe65fcd5f0a90588ba51 (patch)
tree5cefd4971a0e6b5d5f9eacf6d3532c6aedc7b352 /debug
parent64ba17317dc9343f0958755ad04af71ec3da637b (diff)
downloadglibc-db3476aff19b75c4fdefbe65fcd5f0a90588ba51.zip
glibc-db3476aff19b75c4fdefbe65fcd5f0a90588ba51.tar.gz
glibc-db3476aff19b75c4fdefbe65fcd5f0a90588ba51.tar.bz2
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 'debug')
-rw-r--r--debug/obprintf_chk.c2
-rw-r--r--debug/vdprintf_chk.c2
-rw-r--r--debug/vsnprintf_chk.c2
-rw-r--r--debug/vsprintf_chk.c2
4 files changed, 4 insertions, 4 deletions
diff --git a/debug/obprintf_chk.c b/debug/obprintf_chk.c
index 8469b5f..09655ba 100644
--- a/debug/obprintf_chk.c
+++ b/debug/obprintf_chk.c
@@ -35,7 +35,7 @@ struct _IO_obstack_file
struct obstack *obstack;
};
-extern const struct _IO_jump_t _IO_obstack_jumps attribute_hidden;
+extern const struct _IO_jump_t _IO_obstack_jumps libio_vtable attribute_hidden;
int
__obstack_vprintf_chk (struct obstack *obstack, int flags, const char *format,
diff --git a/debug/vdprintf_chk.c b/debug/vdprintf_chk.c
index 05d0bcd..ce0ddb0 100644
--- a/debug/vdprintf_chk.c
+++ b/debug/vdprintf_chk.c
@@ -39,7 +39,7 @@ __vdprintf_chk (int d, int flags, const char *format, va_list arg)
#endif
_IO_no_init (&tmpfil.file, _IO_USER_LOCK, 0, &wd, &_IO_wfile_jumps);
_IO_JUMPS (&tmpfil) = &_IO_file_jumps;
- _IO_file_init (&tmpfil);
+ _IO_new_file_init_internal (&tmpfil);
#if !_IO_UNIFIED_JUMPTABLES
tmpfil.vtable = NULL;
#endif
diff --git a/debug/vsnprintf_chk.c b/debug/vsnprintf_chk.c
index cc559d2..a6bb051 100644
--- a/debug/vsnprintf_chk.c
+++ b/debug/vsnprintf_chk.c
@@ -20,7 +20,7 @@
#include "../libio/libioP.h"
#include "../libio/strfile.h"
-extern const struct _IO_jump_t _IO_strn_jumps attribute_hidden;
+extern const struct _IO_jump_t _IO_strn_jumps libio_vtable attribute_hidden;
/* Write formatted output into S, according to the format
string FORMAT, writing no more than MAXLEN characters. */
diff --git a/debug/vsprintf_chk.c b/debug/vsprintf_chk.c
index aa1587c..02e7372 100644
--- a/debug/vsprintf_chk.c
+++ b/debug/vsprintf_chk.c
@@ -32,7 +32,7 @@ _IO_str_chk_overflow (_IO_FILE *fp, int c)
}
-static const struct _IO_jump_t _IO_str_chk_jumps =
+static const struct _IO_jump_t _IO_str_chk_jumps libio_vtable =
{
JUMP_INIT_DUMMY,
JUMP_INIT(finish, _IO_str_finish),