Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH][gdb/tdep] Handle si_addr_bnd in compat_siginfo_from_siginfo
@ 2021-01-11 10:32 Tom de Vries
  2021-01-18  8:35 ` [committed][gdb/tdep] " Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2021-01-11 10:32 UTC (permalink / raw)
  To: gdb-patches

Hi,

When running test-case gdb.arch/i386-mpx-sigsegv.exp with target board
unix/-m32, we run into:
...
(gdb) continue^M
Continuing.^M
Saw a #BR! status 1 at 0x8048c2d^M
^M
Program received signal SIGSEGV, Segmentation fault^M
Upper bound violation while accessing address 0x0804c15c^M
Bounds: [lower = 0x00000000, upper = 0x00000000].^M
0x08048a4f in lower (p=0x804c160, a=0x804c180, b=0x804c1a0, c=0x804c1c0, \
  d=0x804c1e0, len=1) at i386-mpx-sigsegv.c:79^M
79        value = *(p - len);^M
(gdb) FAIL: gdb.arch/i386-mpx-sigsegv.exp: MPX signal segv Lower: 0
...

The problem is that lower and upper in the Bounds message are 0x0, which is
caused by $_siginfo._sifields._sigfault._addr_bnd.{_lower,_upper} evaluating
to 0x0.

Fix this by copying the si_lower/si_upper fields in
compat_siginfo_from_siginfo.

Tested on x86_64-linux, with target board unix/-m32.

Any comments?

Thanks,
- Tom

[gdb/tdep] Handle si_addr_bnd in compat_siginfo_from_siginfo

gdb/ChangeLog:

2021-01-11  Tom de Vries  <tdevries@suse.de>

	PR tdep/27172
	* nat/amd64-linux-siginfo.c (cpt_si_lower, cpt_si_upper): New
	macro.
	(compat_siginfo_from_siginfo): Copy cpt_si_lower and cpt_si_upper
	for SEGV_BNDERR.

---
 gdb/nat/amd64-linux-siginfo.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index 8bcff454378..e25f2e63851 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -277,6 +277,8 @@ typedef struct compat_x32_siginfo
 #define cpt_si_ptr _sifields._rt._sigval.sival_ptr
 #define cpt_si_addr _sifields._sigfault._addr
 #define cpt_si_addr_lsb _sifields._sigfault._addr_lsb
+#define cpt_si_lower _sifields._sigfault.si_addr_bnd._lower
+#define cpt_si_upper _sifields._sigfault.si_addr_bnd._upper
 #define cpt_si_band _sifields._sigpoll._band
 #define cpt_si_fd _sifields._sigpoll._fd
 
@@ -324,6 +326,13 @@ compat_siginfo_from_siginfo (compat_siginfo_t *to, const siginfo_t *from)
       to->cpt_si_pid = from_ptrace.cpt_si_pid;
       to->cpt_si_uid = from_ptrace.cpt_si_uid;
     }
+  else if (to->si_code == 3 /* SEGV_BNDERR */
+	   && to->si_signo == SIGSEGV)
+    {
+      to->cpt_si_addr = from_ptrace.cpt_si_addr;
+      to->cpt_si_lower = from_ptrace.cpt_si_lower;
+      to->cpt_si_upper = from_ptrace.cpt_si_upper;
+    }
   else if (to->si_code < 0)
     {
       to->cpt_si_pid = from_ptrace.cpt_si_pid;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [committed][gdb/tdep] Handle si_addr_bnd in compat_siginfo_from_siginfo
  2021-01-11 10:32 [PATCH][gdb/tdep] Handle si_addr_bnd in compat_siginfo_from_siginfo Tom de Vries
@ 2021-01-18  8:35 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2021-01-18  8:35 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

On 1/11/21 11:32 AM, Tom de Vries wrote:
> Hi,
> 
> When running test-case gdb.arch/i386-mpx-sigsegv.exp with target board
> unix/-m32, we run into:
> ...
> (gdb) continue^M
> Continuing.^M
> Saw a #BR! status 1 at 0x8048c2d^M
> ^M
> Program received signal SIGSEGV, Segmentation fault^M
> Upper bound violation while accessing address 0x0804c15c^M
> Bounds: [lower = 0x00000000, upper = 0x00000000].^M
> 0x08048a4f in lower (p=0x804c160, a=0x804c180, b=0x804c1a0, c=0x804c1c0, \
>   d=0x804c1e0, len=1) at i386-mpx-sigsegv.c:79^M
> 79        value = *(p - len);^M
> (gdb) FAIL: gdb.arch/i386-mpx-sigsegv.exp: MPX signal segv Lower: 0
> ...
> 
> The problem is that lower and upper in the Bounds message are 0x0, which is
> caused by $_siginfo._sifields._sigfault._addr_bnd.{_lower,_upper} evaluating
> to 0x0.
> 
> Fix this by copying the si_lower/si_upper fields in
> compat_siginfo_from_siginfo.
> 
> Tested on x86_64-linux, with target board unix/-m32.
> 
> Any comments?
> 

Added SEGV_BNDERR define, and committed as below.

Thanks,
- Tom



[-- Attachment #2: 0001-gdb-tdep-Handle-si_addr_bnd-in-compat_siginfo_from_siginfo.patch --]
[-- Type: text/x-patch, Size: 2679 bytes --]

[gdb/tdep] Handle si_addr_bnd in compat_siginfo_from_siginfo

When running test-case gdb.arch/i386-mpx-sigsegv.exp with target board
unix/-m32, we run into:
...
(gdb) continue^M
Continuing.^M
Saw a #BR! status 1 at 0x8048c2d^M
^M
Program received signal SIGSEGV, Segmentation fault^M
Upper bound violation while accessing address 0x0804c15c^M
Bounds: [lower = 0x00000000, upper = 0x00000000].^M
0x08048a4f in lower (p=0x804c160, a=0x804c180, b=0x804c1a0, c=0x804c1c0, \
  d=0x804c1e0, len=1) at i386-mpx-sigsegv.c:79^M
79        value = *(p - len);^M
(gdb) FAIL: gdb.arch/i386-mpx-sigsegv.exp: MPX signal segv Lower: 0
...

The problem is that lower and upper in the Bounds message are 0x0, which is
caused by $_siginfo._sifields._sigfault._addr_bnd.{_lower,_upper} evaluating
to 0x0.

Fix this by copying the si_lower/si_upper fields in
compat_siginfo_from_siginfo.

Tested on x86_64-linux, with target board unix/-m32.

gdb/ChangeLog:

2021-01-11  Tom de Vries  <tdevries@suse.de>

	PR tdep/27172
	* nat/amd64-linux-siginfo.c (cpt_si_lower, cpt_si_upper, SEGV_BNDERR):
	New macro.
	(compat_siginfo_from_siginfo): Copy cpt_si_lower and cpt_si_upper
	for SEGV_BNDERR.

---
 gdb/nat/amd64-linux-siginfo.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index 8bcff454378..0c932814ec8 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -277,6 +277,8 @@ typedef struct compat_x32_siginfo
 #define cpt_si_ptr _sifields._rt._sigval.sival_ptr
 #define cpt_si_addr _sifields._sigfault._addr
 #define cpt_si_addr_lsb _sifields._sigfault._addr_lsb
+#define cpt_si_lower _sifields._sigfault.si_addr_bnd._lower
+#define cpt_si_upper _sifields._sigfault.si_addr_bnd._upper
 #define cpt_si_band _sifields._sigpoll._band
 #define cpt_si_fd _sifields._sigpoll._fd
 
@@ -290,6 +292,10 @@ typedef struct compat_x32_siginfo
 #define si_overrun si_timer2
 #endif
 
+#ifndef SEGV_BNDERR
+#define SEGV_BNDERR	3
+#endif
+
 /* The type of the siginfo object the kernel returns in
    PTRACE_GETSIGINFO.  If gdb is built as a x32 program, we get a x32
    siginfo.  */
@@ -324,6 +330,13 @@ compat_siginfo_from_siginfo (compat_siginfo_t *to, const siginfo_t *from)
       to->cpt_si_pid = from_ptrace.cpt_si_pid;
       to->cpt_si_uid = from_ptrace.cpt_si_uid;
     }
+  else if (to->si_code == SEGV_BNDERR
+	   && to->si_signo == SIGSEGV)
+    {
+      to->cpt_si_addr = from_ptrace.cpt_si_addr;
+      to->cpt_si_lower = from_ptrace.cpt_si_lower;
+      to->cpt_si_upper = from_ptrace.cpt_si_upper;
+    }
   else if (to->si_code < 0)
     {
       to->cpt_si_pid = from_ptrace.cpt_si_pid;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-18  8:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 10:32 [PATCH][gdb/tdep] Handle si_addr_bnd in compat_siginfo_from_siginfo Tom de Vries
2021-01-18  8:35 ` [committed][gdb/tdep] " Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox