lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 23 Nov 2021 15:44:33 +1000
From:   Alistair Francis <alistair23@...il.com>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     André Almeida <andrealmeid@...labora.com>,
        Alistair Francis <alistair.francis@...nsource.wdc.com>,
        Alistair Francis <alistair.francis@....com>,
        Linux API <linux-api@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        "H. Peter Anvin" <hpa@...or.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Darren Hart <dvhart@...radead.org>,
        Davidlohr Bueso <dave@...olabs.net>,
        Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH v2] uapi: futex: Add a futex syscall

On Tue, Oct 26, 2021 at 3:33 AM Arnd Bergmann <arnd@...db.de> wrote:
>
> On Mon, Oct 25, 2021 at 6:33 PM André Almeida <andrealmeid@...labora.com> wrote:
> > Às 02:54 de 21/10/21, Alistair Francis escreveu:
> > > From: Alistair Francis <alistair.francis@....com>
>
> > > +#if defined(__NR_futex)
> > > +     if (sizeof(*timeout) == sizeof(struct __kernel_old_timespec))
> > > +             return syscall(__NR_futex, uaddr, op, val, timeout, uaddr2, val3);
> > > +
> > > +     if (timeout && timeout->tv_sec == (long)timeout->tv_sec) {
> > > +             struct __kernel_old_timespec ts32;
> > > +
> > > +             ts32.tv_sec = (__kernel_long_t) timeout->tv_sec;> +             ts32.tv_nsec = (__kernel_long_t) timeout->tv_nsec;
> > > +
> > > +             return syscall(__NR_futex, uaddr, op, val, &ts32, uaddr2, val3);
> > > +     } else if (!timeout) {
> > > +             return syscall(__NR_futex, uaddr, op, val, NULL, uaddr2, val3);
> > > +     }
> > > +#endif
> >
> > If I read this part right, you will always use ts32 for __NR_futex. I
> > know that it can be misleading, but __NR_futex uses ts64 in 64-bit
> > archs, so they shouldn't be converted to ts32 in those cases.
>
> __kernel_old_timespec is the correct type for sys_futex() on all
> architectures.
>
> Maybe name the local variable 'ts' or 'ts_old' instead of 'ts32' then?
>
> > > +{
> > > +#if defined(__NR_futex_time64)
> > > +     int ret =  syscall(__NR_futex_time64, uaddr, op, val, nr_requeue, uaddr2, val3);
> > > +
> > > +     if (ret == 0 || errno != ENOSYS)
> > > +             return ret;
> > > +#endif
> > > +
> > > +#if defined(__NR_futex)
> > > +     return syscall(__NR_futex, uaddr, op, val, nr_requeue, uaddr2, val3);
> > > +#endif
> > > +
> > > +     errno = ENOSYS;
> > > +     return -1;
> > > +}
> > > +
> > > +#endif /* _UAPI_LINUX_FUTEX_SYSCALL_H */
> > >
> >
> > Sorry if this question was already asked but I didn't find it in the
> > thread: Should we go with wrappers for the most common op? Like:
> >
> > __kernel_futex_wait(volatile uint32_t *uaddr, uint32_t val, struct
> > timespec *timeout)
> >
> > __kernel_futex_wake(volatile uint32_t *uaddr, uint32_t nr_wake)
>
> I had suggested having just a single function definition here, but having one
> per argument type seems reasonable as well. Having one definition
> per futex_op value would also be possible, but in that case I suppose
> we need all 13 of them, not just two.

Sorry I have taken so long to look at this again. I have addressed
your other comments.

I don't have a strong preference here. I do like that by having a
generic __kernel_futex_syscall_timeout() it should be easier to
convert existing uses of SYSCALL() to the new function (the requeue is
it's own thing anyway).

Alistair

>
>         Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ