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.129.124]) by sourceware.org (Postfix) with ESMTPS id 4B4253858C66 for ; Thu, 30 Nov 2023 09:54:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B4253858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4B4253858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701338083; cv=none; b=Nr8AmLC2vxuclRpMJcrGfOztUm6tFezy+9StzQVujHfv1HdLiL2on3YLMmE5qUI77rMiMeRICSEPThSMO8eRH4Sl4FRdY79Eu1SyKMy1LY9CDRi+G6gWqaKlOdtwDcJvGBYfVJEjxyfO3saiSB1tP+eQCjzKKpCGg+ZM2U7O4so= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701338083; c=relaxed/simple; bh=9R5cWpcK6LcDYiIy7TwBRTPqTZJNq5MYmEXL6zAAphk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=D6z0WBoTQIigs/SMNoypuptA+KH+DJYqIE156OfMKqFdLECAWWOSTqXb4+thkeQTI/EcAYT73iLitiK7clGjvpWOudhRk5VvEEWcDoHp4HCAYdS+HtjBNn6LdKSlw1vUOsUoqueR2apTUDCuY2NRqCQI3Tvc9bMKw0OjhON15jY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701338081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cuxt+XUO7QFDS0JOH4yL5K5Gz0SFJdEh/NeOma6Q33I=; b=aMjyQGk8LnTfCDSpy9Bv84U/ASq9Shj7zBzgSmVbtjHPfbz3DT/LA4Vur0V8r2sPWvHISC zUrtQIiyTmvOJEwGxHQiufdfiiaB0KczujrhpxeVM7njF0GIWexF588ksv9yjjVAy0dtFf 0fuPM7AfU8A1BFdk85Dd0JaVGmAFyug= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-139-dvej8tSpOg2sJWoyXICYzA-1; Thu, 30 Nov 2023 04:54:38 -0500 X-MC-Unique: dvej8tSpOg2sJWoyXICYzA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AE76588D188; Thu, 30 Nov 2023 09:54:37 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22CFEC1596F; Thu, 30 Nov 2023 09:54:37 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella via Libc-alpha Cc: Paul Eggert , Adhemerval Zanella Subject: Re: [PATCH v2] linux: Make fdopendir fail with O_PATH (BZ 30373) References: <20230901122651.59253-1-adhemerval.zanella@linaro.org> Date: Thu, 30 Nov 2023 10:54:35 +0100 In-Reply-To: <20230901122651.59253-1-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Fri, 1 Sep 2023 09:26:51 -0300") Message-ID: <875y1jwopw.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 List-Id: * Adhemerval Zanella via Libc-alpha: > diff --git a/sysdeps/unix/sysv/linux/fdopendir.c b/sysdeps/unix/sysv/linux/fdopendir.c > index 861345396c..707fb5960e 100644 > --- a/sysdeps/unix/sysv/linux/fdopendir.c > +++ b/sysdeps/unix/sysv/linux/fdopendir.c > @@ -37,10 +37,16 @@ __fdopendir (int fd) > return NULL; > } > > - /* Make sure the descriptor allows for reading. */ > int flags = __fcntl64_nocancel (fd, F_GETFL); > if (__glibc_unlikely (flags == -1)) > return NULL; > + /* Fail early for descriptors opened with O_PATH. */ > + if (__glibc_unlikely (flags & O_PATH)) > + { > + __set_errno (EBADF); > + return NULL; > + } Should we fail with EINVAL instead of EBADF? Maybe add a comment that EBADF matches what readdir will fail with? Otherwise: Reviewed-by: Florian Weimer Thanks, Florian