|
Message-ID: <20230212200425.GP4163@brightrain.aerifal.cx> Date: Sun, 12 Feb 2023 15:04:26 -0500 From: Rich Felker <dalias@...c.org> To: musl@...ts.openwall.com Subject: Re: [PATCH] mq_notify: fix close/recv race on failure path 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.