From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94317 invoked by alias); 19 Jan 2017 15:02:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 93774 invoked by uid 89); 19 Jan 2017 15:02:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Might, H*i:sk:A78C989, H*f:sk:A78C989 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Jan 2017 15:02:13 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92D26C0567B5; Thu, 19 Jan 2017 15:02:13 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0JF2B91019779; Thu, 19 Jan 2017 10:02:12 -0500 Subject: Re: [PATCH 1/2] gdbserver: catch fetch registers error To: "Metzger, Markus T" , "gdb-patches@sourceware.org" References: <1481039697-17596-1-git-send-email-markus.t.metzger@intel.com> <1481039697-17596-2-git-send-email-markus.t.metzger@intel.com> <07c4f2ec-25b7-7a42-bc57-a64045a65f9e@redhat.com> Cc: Daniel Jacobowitz From: Pedro Alves Message-ID: <3645afe3-33e6-9ee2-71dc-25a94d1008b7@redhat.com> Date: Thu, 19 Jan 2017 15:02:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-01/txt/msg00385.txt.bz2 On 01/19/2017 02:48 PM, Metzger, Markus T wrote: > Hello Pedro, > > Thanks for the review and the elaborate response. > >> The case of trying to read registers from a thread that is >> running is always a client bug. GDB should know which threads >> it resumed, and checks like the validate_registers_access >> you found should prevent such accesses reaching the server. > > That's a general misunderstanding of the design on my part, then. I typically > don't check if I can/should do something but instead just do it and handle errors > in case it failed. Like reading registers. > > Let me drop this patch and instead call validate_registers_access in btrace before > reading the PC. We have similar checks in other places, like e.g., frame.c:has_stack_frames. Might make sense to factor things out a bit to avoid a throw/catch. >> So it seems to me that btrace shouldn't even be trying to be enabled >> on running threads. > > It works fine and I didn't see a reason why we would not want to allow it. Sorry, that was bogus. I agree -- what it shouldn't be doing is reading registers. Thanks, Pedro Alves