From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8D317385741B for ; Fri, 29 Jul 2022 15:53:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D317385741B Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-216-pF2WlvW4NeaPatCm4Z5zFA-1; Fri, 29 Jul 2022 11:53:09 -0400 X-MC-Unique: pF2WlvW4NeaPatCm4Z5zFA-1 Received: by mail-qt1-f197.google.com with SMTP id w26-20020a05622a191a00b0031f0b4a561bso3145505qtc.21 for ; Fri, 29 Jul 2022 08:53:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=UP3/N5VleWOsgVvaPYUnkLE/h7arQ+mRTz7VHKiVNTw=; b=FPc4CfAEXM78oC3LbXLZs7xBa2UD/dexblxZM11DhNo6gAtBITAb4Gq3ZC+dn3lKNj jF3rc34Gwng3JvU4k9Jj3SqpfeZwtA9Iz3Y3NzoW0LzkhIn0wkHfjAAr/fHUkVTl0Vah QJWZh7dPtJSBSUNmCzYlU2cNi+SaymAUfbmNatSlghRXITYP3m88AknNmuTRYo9YxNE1 OchwGRKDagOBk9wvJoS8fPVXXDAWnJWXhXjV62h8NXE/C4IcrGq0NgJB4enbkJSz7M2f V3kh9E4UWrIfrGYR8Mz2Pur3XTGhQ5XeMyuMmIY/BXcouD8wvkp3G9Db4Ejfgw8M2zr2 Qdcg== X-Gm-Message-State: AJIora8nc2yTbtkKZ4VhggAAW566hz6AVIDnS0NmbPlBUM5Kbgjy7W7H F9Su9XOUK+f656Xl19mPeAgUhHKDfBcRHWP19bVYD5N4PdhK7OeYcq3+YtHSAsOuhgf1N32pXMN LVybcD9+GVlIEWq/xQ9wa X-Received: by 2002:ac8:57c4:0:b0:31f:100:fc59 with SMTP id w4-20020ac857c4000000b0031f0100fc59mr4028939qta.395.1659109988623; Fri, 29 Jul 2022 08:53:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uYxFeGZFY9QIsYB6IuRO5CZzSqMgQpRz3WKqRkmrzzxobLlODPDyzyBmxGTdkLDNJZxtlFPA== X-Received: by 2002:ac8:57c4:0:b0:31f:100:fc59 with SMTP id w4-20020ac857c4000000b0031f0100fc59mr4028927qta.395.1659109988371; Fri, 29 Jul 2022 08:53:08 -0700 (PDT) Received: from [192.168.0.241] (192-0-145-146.cpe.teksavvy.com. [192.0.145.146]) by smtp.gmail.com with ESMTPSA id h13-20020a05620a284d00b006af59e9ddeasm2686493qkp.18.2022.07.29.08.53.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Jul 2022 08:53:07 -0700 (PDT) Message-ID: <18e52816-a390-6964-5c2b-efd3aa16c537@redhat.com> Date: Fri, 29 Jul 2022 11:53:07 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCHv5] tst-pidfd.c: UNSUPPORTED if we get EPERM on valid pidfd_getfd call To: Mark Wielaard Cc: libc-alpha@sourceware.org, Adhemerval Zanella References: <20220719131419.21312-1-mark@klomp.org> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <20220719131419.21312-1-mark@klomp.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP 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: , X-List-Received-Date: Fri, 29 Jul 2022 15:53:11 -0000 On 7/19/22 09:14, Mark Wielaard wrote: > pidfd_getfd can fail for a valid pidfd with errno EPERM for various > reasons in a restricted environment. Use FAIL_UNSUPPORTED in that case. > > Reviewed-by: Adhemerval Zanella OK for 2.36. OK from the RM (me). This is very limited in scope and solves the problem with downstream buildbot testing for the 2.36 release. Thanks for working through this issue! Reviewed-by: Carlos O'Donell > --- > > v5: Add comment why the EPERM check is needed and which credential > checks are performed > v4: Drop all EPERM checks except on the actual (valid) pidfd_getfd > v3: Also test for EPERM on pidfd_open, don't mention > PTRACE_MODE_ATTACH_REALCREDS since it is just one reason for > getting EPERM. > v2: separate ENOSYS and EPERM checks and FAIL_UNSUPPORTED messages > > https://code.wildebeest.org/git/user/mjw/glibc/commit/?h=container-perms&id=435a8361ef3e2ce64bb7a48760adea577797967e > > sysdeps/unix/sysv/linux/tst-pidfd.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/sysdeps/unix/sysv/linux/tst-pidfd.c b/sysdeps/unix/sysv/linux/tst-pidfd.c > index d93b6faa6f..037af22290 100644 > --- a/sysdeps/unix/sysv/linux/tst-pidfd.c > +++ b/sysdeps/unix/sysv/linux/tst-pidfd.c > @@ -142,6 +142,13 @@ do_test (void) > xrecvfrom (sockets[0], &remote_fd, sizeof (remote_fd), 0, NULL, 0); > > int fd = pidfd_getfd (pidfd, remote_fd, 0); > + /* pidfd_getfd may fail with EPERM if the process does not have > + PTRACE_MODE_ATTACH_REALCREDS permissions. This means the call > + may be denied if the process doesn't have CAP_SYS_PTRACE or > + if a LSM security_ptrace_access_check denies access. */ > + if (fd == -1 && errno == EPERM) > + FAIL_UNSUPPORTED ("don't have permission to use pidfd_getfd on pidfd, " > + "skipping test"); > TEST_VERIFY (fd > 0); > > char *path = xasprintf ("/proc/%d/fd/%d", pid, remote_fd); -- Cheers, Carlos.