From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117253 invoked by alias); 26 Aug 2019 20:51:19 -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 117103 invoked by uid 89); 26 Aug 2019 20:51:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= 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; Mon, 26 Aug 2019 20:51:17 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFC9046673; Mon, 26 Aug 2019 20:51:16 +0000 (UTC) Received: from localhost (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A8C35D6C8; Mon, 26 Aug 2019 20:51:16 +0000 (UTC) From: Sergio Durigan Junior To: Christian Biesinger Cc: GDB Patches , Pedro Alves , Eli Zaretskii , Ruslan Kabatsayev Subject: Re: [PATCH v2] Improve ptrace-error detection on Linux targets References: <20190819032918.3536-1-sergiodj@redhat.com> <20190826183205.19008-1-sergiodj@redhat.com> Date: Mon, 26 Aug 2019 20:51:00 -0000 In-Reply-To: (Christian Biesinger's message of "Mon, 26 Aug 2019 13:35:14 -0500") Message-ID: <87r257zm4b.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00605.txt.bz2 On Monday, August 26 2019, Christian Biesinger wrote: > On Mon, Aug 26, 2019 at 1:32 PM Sergio Durigan Junior > wrote: >> @@ -30,11 +32,70 @@ >> of 0 means there are no supported features. */ >> static int supported_ptrace_options = -1; >> >> -/* Find all possible reasons we could fail to attach PID and return these >> - as a string. An empty string is returned if we didn't find any reason. */ >> +typedef int (*selinux_ftype) (const char *); >> + >> +/* Helper function which checks if ptrace is probably restricted >> + (i.e., if ERR is either EACCES or EPERM), and returns a string with >> + possible workarounds. */ >> + >> +static std::string >> +linux_ptrace_restricted_fail_reason (int err) >> +{ >> + if (err != EACCES && err != EPERM) >> + { >> + /* It just makes sense to perform the checks below if errno was >> + either EACCES or EPERM. */ >> + return {}; >> + } >> + >> + std::string ret; >> + gdb_dlhandle_up handle = gdb_dlopen ("libselinux.so", true); > > I would dlopen libselinux.so.1 instead so that this works even without > the -dev package. Ah, right, I forgot about this. I fixed it in my local copy, thanks for pointing it out. -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/