public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Cc: Paul Eggert <eggert@cs.ucla.edu>,
	 Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH v2] linux: Make fdopendir fail with O_PATH (BZ 30373)
Date: Thu, 30 Nov 2023 10:54:35 +0100	[thread overview]
Message-ID: <875y1jwopw.fsf@oldenburg.str.redhat.com> (raw)
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")

* 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 <fweimer@redhat.com>

Thanks,
Florian


  parent reply	other threads:[~2023-11-30  9:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-01 12:26 Adhemerval Zanella
2023-09-01 17:57 ` Paul Eggert
2023-09-05 12:07   ` Adhemerval Zanella Netto
2023-10-02 11:09 ` Adhemerval Zanella Netto
2023-11-29 16:54   ` Adhemerval Zanella Netto
2023-11-30  9:54 ` Florian Weimer [this message]
2023-11-30 11:51   ` Adhemerval Zanella Netto
  -- strict thread matches above, loose matches on Subject: below --
2023-09-01 12:23 Adhemerval Zanella
2023-08-10 13:54 Adhemerval Zanella
2023-08-31 17:43 ` Adhemerval Zanella Netto
2023-08-31 20:21 ` Paul Eggert
2023-09-01 12:22   ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875y1jwopw.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).