From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 4B102385840F for ; Thu, 17 Mar 2022 11:56:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4B102385840F Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 22HBu6jf025168 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Mar 2022 07:56:11 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 22HBu6jf025168 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 9D0941EA69; Thu, 17 Mar 2022 07:56:06 -0400 (EDT) Message-ID: <324c1d23-d66a-695d-4e70-7026514698dc@polymtl.ca> Date: Thu, 17 Mar 2022 07:56:06 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v2 3/4] gdb: testsuite: use gdb_attach to fix attach-pie-noexec.exp Content-Language: en-US To: Tiezhu Yang , gdb-patches@sourceware.org Cc: Pedro Alves References: <1647492213-21824-1-git-send-email-yangtiezhu@loongson.cn> <1647492213-21824-4-git-send-email-yangtiezhu@loongson.cn> From: Simon Marchi In-Reply-To: <1647492213-21824-4-git-send-email-yangtiezhu@loongson.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 17 Mar 2022 11:56:07 +0000 X-Spam-Status: No, score=-3038.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 17 Mar 2022 11:56:20 -0000 On 2022-03-17 00:43, Tiezhu Yang wrote: > If /proc/sys/kernel/yama/ptrace_scope is 1, when execute the following > command without superuser: > > make check-gdb TESTS="gdb.base/attach-pie-noexec.exp" > > we can see the following messages in gdb/testsuite/gdb.log: > > (gdb) attach 6500 > Attaching to process 6500 > ptrace: Operation not permitted. > (gdb) PASS: gdb.base/attach-pie-noexec.exp: attach > > It is obviously wrong, the expected result should be UNSUPPORTED in such > a case. > > With this patch, we can see "Operation not permitted" in the log info, > and then we can do the following processes to test: > (1) set ptrace_scope as 0 > $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope > $ make check-gdb TESTS="gdb.base/attach-pie-noexec.exp" > (2) use sudo > $ sudo make check-gdb TESTS="gdb.base/attach-pie-noexec.exp" > > Signed-off-by: Tiezhu Yang > --- > gdb/testsuite/gdb.base/attach-pie-noexec.exp | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.base/attach-pie-noexec.exp b/gdb/testsuite/gdb.base/attach-pie-noexec.exp > index 4712824..9a1bafe 100644 > --- a/gdb/testsuite/gdb.base/attach-pie-noexec.exp > +++ b/gdb/testsuite/gdb.base/attach-pie-noexec.exp > @@ -59,7 +59,9 @@ set testpid [spawn_id_get_pid $test_spawn_id] > > gdb_start > file delete -- $binfile > -gdb_test "attach $testpid" "Attaching to process $testpid\r\n.*" "attach" > +if {![gdb_attach $testpid]} { > + return 0 > +} You can do just "return", I don't think that return value is used anywhere. LGTM with that. Simon