From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id PP4AEF1IBWDyFgAAWB0awg (envelope-from ) for ; Mon, 18 Jan 2021 03:35:41 -0500 Received: by simark.ca (Postfix, from userid 112) id 343E71EF80; Mon, 18 Jan 2021 03:35:41 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4B3A61E590 for ; Mon, 18 Jan 2021 03:35:40 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C4C523858D33; Mon, 18 Jan 2021 08:35:39 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id A20BF3858D33 for ; Mon, 18 Jan 2021 08:35:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A20BF3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BFD48AB7F for ; Mon, 18 Jan 2021 08:35:35 +0000 (UTC) Subject: [committed][gdb/tdep] Handle si_addr_bnd in compat_siginfo_from_siginfo From: Tom de Vries To: gdb-patches@sourceware.org References: <20210111103255.GA540@delia> Message-ID: <8d3ff00d-0cf3-51fc-da81-c1150aef112c@suse.de> Date: Mon, 18 Jan 2021 09:35:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20210111103255.GA540@delia> Content-Type: multipart/mixed; boundary="------------F37657AA5D8E918D2280B370" Content-Language: en-US X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This is a multi-part message in MIME format. --------------F37657AA5D8E918D2280B370 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 --------------F37657AA5D8E918D2280B370 Content-Type: text/x-patch; charset=UTF-8; name="0001-gdb-tdep-Handle-si_addr_bnd-in-compat_siginfo_from_siginfo.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-gdb-tdep-Handle-si_addr_bnd-in-compat_siginfo_from_sigi"; filename*1="nfo.patch" [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 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; --------------F37657AA5D8E918D2280B370--