From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id p4yPDGAp/F9sEwAAWB0awg (envelope-from ) for ; Mon, 11 Jan 2021 05:33:04 -0500 Received: by simark.ca (Postfix, from userid 112) id 22A871EEEF; Mon, 11 Jan 2021 05:33:04 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILING_LIST_MULTI,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 A711B1E4F4 for ; Mon, 11 Jan 2021 05:33:03 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 21296385800B; Mon, 11 Jan 2021 10:33:03 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id F1690385800B for ; Mon, 11 Jan 2021 10:32:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F1690385800B 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 17EC1ABC4 for ; Mon, 11 Jan 2021 10:32:59 +0000 (UTC) Date: Mon, 11 Jan 2021 11:32:56 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/tdep] Handle si_addr_bnd in compat_siginfo_from_siginfo Message-ID: <20210111103255.GA540@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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" 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 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;