From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] mq_notify: fix close/recv race on failure path
Date: Sun, 12 Feb 2023 15:04:26 -0500 [thread overview]
Message-ID: <20230212200425.GP4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <e900e7f2809d4b97241bff2e8f262ec8@ispras.ru>
On Sun, Feb 12, 2023 at 10:35:39PM +0300, Alexey Izbyshev wrote:
> On 2023-02-12 21:23, Alexey Izbyshev wrote:
> >On 2023-02-12 03:32, Rich Felker wrote:
> >diff --git a/src/mq/mq_notify.c b/src/mq/mq_notify.c
> >index a42888d2..8eac71ed 100644
> >--- a/src/mq/mq_notify.c
> >+++ b/src/mq/mq_notify.c
> >@@ -10,6 +10,8 @@
> > struct args {
> > sem_t sem;
> > int sock;
> >+ mqd_t mqd;
> >+ int err;
> > const struct sigevent *sev;
> > };
> >
> >@@ -21,8 +23,21 @@ static void *start(void *p)
> > int s = args->sock;
> > void (*func)(union sigval) = args->sev->sigev_notify_function;
> > union sigval val = args->sev->sigev_value;
> >+ struct sigevent sev2;
> >+ static const char zeros[32];
> >+ int err = 0;
> >
> >+ sev2.sigev_notify = SIGEV_THREAD;
> >+ sev2.sigev_signo = s;
> >+ sev2.sigev_value.sival_ptr = (void *)&zeros;
> >+
> >+ err = 0;
> >
> >This assignment is redundant.
> >
> >Maybe this hunk could be simplified by getting rid of err and simply
> >doing "args->err = -__syscall(SYS_mq_notify, args->mqd, &sev2)".
> >
> Never mind, err is needed because we can't access args->err after
> sem_post.
Yep. I'll still switch to __syscall and get rid of the redundant
initialization but err is needed since we can't access args later.
Rich
prev parent reply other threads:[~2023-02-12 20:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 10:46 Alexey Izbyshev
2022-12-14 2:26 ` Rich Felker
2022-12-14 6:49 ` Alexey Izbyshev
2023-02-10 16:29 ` Rich Felker
2023-02-11 14:45 ` Alexey Izbyshev
2023-02-11 14:52 ` Rich Felker
2023-02-11 15:13 ` Alexey Izbyshev
2023-02-11 15:06 ` Rich Felker
2023-02-11 17:13 ` Markus Wichmann
2023-02-11 17:46 ` Rich Felker
2023-02-11 17:50 ` Alexey Izbyshev
2023-02-11 17:59 ` Rich Felker
2023-02-11 18:08 ` Alexey Izbyshev
2023-02-11 18:35 ` Rich Felker
2023-02-11 19:28 ` Alexey Izbyshev
2023-02-11 19:49 ` Rich Felker
2023-02-11 20:14 ` Alexey Izbyshev
2023-02-12 0:32 ` Rich Felker
2023-02-12 18:23 ` Alexey Izbyshev
2023-02-12 19:35 ` Alexey Izbyshev
2023-02-12 20:04 ` Rich Felker [this message]
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=20230212200425.GP4163@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/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).