mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Tamir Duberstein <tamird@google.com>
To: NRK <nrk@disroot.org>
Cc: Rich Felker <dalias@libc.org>, musl@lists.openwall.com
Subject: Re: [musl] undefined behavior in fread.c
Date: Fri, 24 Feb 2023 09:42:00 -0500	[thread overview]
Message-ID: <CAK-_uh655WeD52j426MnxGG1F6N-MW3OtkHMsSzEnhf5suxSsw@mail.gmail.com> (raw)
In-Reply-To: <20230224141731.dm4w7fbfkczbx42e@gen2.localdomain>

[-- Attachment #1: Type: text/plain, Size: 702 bytes --]

We could take the lock and still avoid UB with an early return.

On Fri, Feb 24, 2023, 09:17 NRK <nrk@disroot.org> wrote:

> On Fri, Feb 24, 2023 at 09:07:41AM -0500, Rich Felker wrote:
> > stdio functions are required (by POSIX) to behave as if they take a
> > mutex on the FILE. If fread with a length of zero makes forward
> > progress when another thread holds the lock, this is non-conforming.
>
> OK, I see. Wasn't aware of that.
>
> On a sidenote, if I'm reading the right function (libio/iofread.c) then
> glibc is taking the lock _after_ they do the size check.
>
>           if (bytes_requested == 0)
>             return 0;
>           _IO_acquire_lock (fp);
>         /* ... */
>
> - NRK
>

[-- Attachment #2: Type: text/html, Size: 1046 bytes --]

  reply	other threads:[~2023-02-24 14:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 12:52 Tamir Duberstein
2023-02-24 13:34 ` Rich Felker
2023-02-24 13:53   ` Jₑₙₛ Gustedt
2023-02-24 13:55   ` NRK
2023-02-24 14:07     ` Rich Felker
2023-02-24 14:17       ` NRK
2023-02-24 14:42         ` Tamir Duberstein [this message]
2023-02-24 15:13           ` NRK
2023-02-24 16:12             ` Tamir Duberstein
2023-02-24 16:40               ` Jₑₙₛ Gustedt
2023-02-24 16:42                 ` Tamir Duberstein
2023-02-24 17:00                   ` Jₑₙₛ Gustedt
2023-02-24 17:07                     ` enh
2023-02-24 17:32                       ` Tamir Duberstein
2023-02-24 16:42                 ` enh
2023-02-24 20:07                 ` Rich Felker

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=CAK-_uh655WeD52j426MnxGG1F6N-MW3OtkHMsSzEnhf5suxSsw@mail.gmail.com \
    --to=tamird@google.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=nrk@disroot.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).