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]
Message-ID: <CAK8P3a2R=e7we11Gi2zTVwFYrEt9Di6Bgzi9xtjMAX9BZex7Cw@mail.gmail.com>
Date:   Mon, 25 Oct 2021 19:32:49 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     André Almeida <andrealmeid@...labora.com>
Cc:     Alistair Francis <alistair.francis@...nsource.wdc.com>,
        Alistair Francis <alistair23@...il.com>,
        Arnd Bergmann <arnd@...db.de>,
        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 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.

        Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ