From patchwork Sun Jul 7 09:39:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1128620 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-504531-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="EBSFQOY5"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45hNpL1Lw4z9s8m for ; Sun, 7 Jul 2019 19:39:31 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=IcJf8TqGTXGcReiKCZAVuysrA/wM6fvs2cIyTJ4Q4zLe4gZXcMGdt /AYqdlRnYqPm59BWWznVB0P/JUA7WbO6dTYHb5+3wwG3SkFdiWiQLM1mxbDStp1m YmadtHrjZmgeXG6behN9kGUW1NRBFGuLhqwGjsDZ1do6KaWnsCBeUc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=NgvQxaI0pFu70Dvne4mm4elUWeE=; b=EBSFQOY5udfn5HadQrY4 Wbd1Z5kZgU+g1qWccKtw2JEOzChUBGlB8iELrDLz/L1z7lu/ET4holgSdUcEdg6M fANd0FDSSrWGzynFhEIHy/y2Htz5ef7e5XpVsa9swTimRvteDWUD9CcpV9BC9YlC /dckxLEPM7mTgaL2jpcGua4= Received: (qmail 3971 invoked by alias); 7 Jul 2019 09:39:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 3959 invoked by uid 89); 7 Jul 2019 09:39:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 07 Jul 2019 09:39:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EA484360 for ; Sun, 7 Jul 2019 02:39:14 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8DC3D3F246 for ; Sun, 7 Jul 2019 02:39:14 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Make guality.h handle Yama restricted ptrace mode Date: Sun, 07 Jul 2019 10:39:13 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 guality.exp is silently skipped on Linux systems with kernel.yama.ptrace_scope=1 because gdb fails to attach to the sanity check test. This patch uses PR_SET_PTRACER (where available) to avoid this. prctl was apparently added in Linux 2.1.57, so I don't think we need any tests other than __linux for the #include. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2019-07-07 Richard Sandiford gcc/testsuite/ * gcc.dg/guality/guality.h: Include on Linux targets. (main): Use PR_SET_PTRACER where available. Index: gcc/testsuite/gcc.dg/guality/guality.h =================================================================== --- gcc/testsuite/gcc.dg/guality/guality.h 2019-03-08 18:15:03.052868249 +0000 +++ gcc/testsuite/gcc.dg/guality/guality.h 2019-07-07 10:18:20.240698144 +0100 @@ -23,6 +23,9 @@ the Free Software Foundation; either ver #include #include #include +#ifdef __linux +#include +#endif /* This is a first cut at checking that debug information matches run-time. The idea is to annotate programs with GUALCHK* macros @@ -214,6 +217,10 @@ main (int argc, char *argv[]) int i; char *argv0 = argv[0]; +#if defined(PR_SET_PTRACER_ANY) + prctl (PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0); +#endif + guality_gdb_command = getenv ("GUALITY_GDB"); if (!guality_gdb_command) {