From patchwork Mon Jun 27 10:50:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 55440 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AD2C43841479 for ; Mon, 27 Jun 2022 10:50:51 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id DCE17386F0F9 for ; Mon, 27 Jun 2022 10:50:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DCE17386F0F9 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from tarox.wildebeest.org (83-87-18-245.cable.dynamic.v4.ziggo.nl [83.87.18.245]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id B4AC330005B6; Mon, 27 Jun 2022 12:50:24 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 71FCC4000C41; Mon, 27 Jun 2022 12:50:24 +0200 (CEST) From: Mark Wielaard To: libc-alpha@sourceware.org Subject: [PATCHv2] tst-pidfd.c: Test is UNSUPPORTED without PTRACE_MODE_ATTACH_REALCREDS Date: Mon, 27 Jun 2022 12:50:16 +0200 Message-Id: <20220627105016.4633-1-mark@klomp.org> X-Mailer: git-send-email 2.18.4 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Wielaard Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" pidfd_getfd will fail with errno EPERM if the calling process did not have PTRACE_MODE_ATTACH_REALCREDS permissions. Use FAIL_UNSUPPORTED in that case. --- v2: separate ENOSYS and EPERM checks and FAIL_UNSUPPORTED messages https://code.wildebeest.org/git/user/mjw/glibc/commit/?h=container-perms&id=5b3288ce83c920b84efb589ad1e434035d873eb9 sysdeps/unix/sysv/linux/tst-pidfd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sysdeps/unix/sysv/linux/tst-pidfd.c b/sysdeps/unix/sysv/linux/tst-pidfd.c index d93b6faa6f..8a6db8fe01 100644 --- a/sysdeps/unix/sysv/linux/tst-pidfd.c +++ b/sysdeps/unix/sysv/linux/tst-pidfd.c @@ -92,11 +92,16 @@ do_test (void) { /* The pidfd_getfd syscall was the last in the set of pidfd related syscalls added to the kernel. Use pidfd_getfd to decide if this - kernel has pidfd support that we can test. */ + kernel has pidfd support that we can test. And that we have + PTRACE_MODE_ATTACH_REALCREDS permissions to use pidfd_getfd. */ int r = pidfd_getfd (0, 0, 1); TEST_VERIFY_EXIT (r == -1); if (errno == ENOSYS) FAIL_UNSUPPORTED ("kernel does not support pidfd_getfd, skipping test"); + if (errno == EPERM) + FAIL_UNSUPPORTED ("don't have permission to use pidfd_getfd " + "(missing PTRACE_MODE_ATTACH_REALCREDS?), " + "skipping test"); } ppid = getpid ();