diff options
author | Walfred Tedeschi <walfred.tedeschi@intel.com> | 2017-03-07 13:53:41 +0100 |
---|---|---|
committer | Walfred Tedeschi <walfred.tedeschi@intel.com> | 2017-03-07 13:53:41 +0100 |
commit | 4a612d6f67d605f480ce7eec7fd9ca1cd1087b35 (patch) | |
tree | 326f4d3f1a5c7e1aebe2abeef5b7b3fc1d3e22ef /gdb/i386-tdep.c | |
parent | ea86f5344298e24801c262d9b52afcc9cb692959 (diff) | |
download | gdb-4a612d6f67d605f480ce7eec7fd9ca1cd1087b35.zip gdb-4a612d6f67d605f480ce7eec7fd9ca1cd1087b35.tar.gz gdb-4a612d6f67d605f480ce7eec7fd9ca1cd1087b35.tar.bz2 |
amd64-mpx: initialize BND register before performing inferior calls.
This patch initializes the BND registers before executing the inferior
call. BND registers can be in arbitrary values at the moment of the
inferior call. In case the function being called uses as part of the
parameters BND register, e.g. when passing a pointer as parameter, the
current value of the register will be used. This can cause boundary
violations that are not due to a real bug or even desired by the user.
In this sense the best to be done is set the BND registers to allow
access to the whole memory, i.e. initialized state, before pushing the
inferior call.
2017-03-07 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* i387-tdep.h (i387_reset_bnd_regs): Add function definition.
* i387-tdep.c (i387_reset_bnd_regs): Add function implementation.
* i386-tdep.c (i386_push_dummy_call): Call i387_reset_bnd_regs.
* amd64-tdep (amd64_push_dummy_call): Call i387_reset_bnd_regs.
gdb/testsuite/ChangeLog:
* i386-mpx-call.c: New file.
* i386-mpx-call.exp: New file.
gdb/doc/ChangeLog:
* Memory Protection Extensions: Add information about inferior
calls.
Diffstat (limited to 'gdb/i386-tdep.c')
-rw-r--r-- | gdb/i386-tdep.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index c81f3e0..ec8b5d3 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2684,6 +2684,13 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int write_pass; int args_space = 0; + /* BND registers can be in arbitrary values at the moment of the + inferior call. This can cause boundary violations that are not + due to a real bug or even desired by the user. The best to be done + is set the BND registers to allow access to the whole memory, INIT + state, before pushing the inferior call. */ + i387_reset_bnd_regs (gdbarch, regcache); + /* Determine the total space required for arguments and struct return address in a first pass (allowing for 16-byte-aligned arguments), then push arguments in a second pass. */ |