Re: [PATCH] futex: Change 'utime' parameter to be 'const ... *'

Started by Alejandro Colomar (man-pages) on Dec 10, 2020 · 2 messages from 1 author · Last reply Jan 17, 2021

open the first message on its own page

Message details and related content
Hi Thomas & Ingo,

I tested the changes. Everything's OK.

Cheers,

Alex

$ uname -a
Linux debian 5.10.0-rc7+alx3+ #4 SMP Thu Dec 10 18:05:03 CET 2020 x86_64
GNU/Linux

.../linux/tools/testing/selftests/futex$ sudo ./run.sh
[sudo] password for user:

TAP version 13
1..1
# futex_requeue_pi: Test requeue functionality
# 	Arguments: broadcast=0 locked=0 owner=0 timeout=0ns
ok 1 futex-requeue-pi
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
TAP version 13
1..1
# futex_requeue_pi: Test requeue functionality
# 	Arguments: broadcast=1 locked=0 owner=0 timeout=0ns
ok 1 futex-requeue-pi
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
TAP version 13
1..1
# futex_requeue_pi: Test requeue functionality
# 	Arguments: broadcast=1 locked=1 owner=0 timeout=0ns
ok 1 futex-requeue-pi
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
TAP version 13
1..1
# futex_requeue_pi: Test requeue functionality
# 	Arguments: broadcast=1 locked=0 owner=1 timeout=0ns
ok 1 futex-requeue-pi
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
TAP version 13

137 more lines

futex(2) says that 'utime' is a pointer to 'const'.
The implementation doesn't use 'const';
however, it _never_ modifies the contents of utime.

- futex() either uses 'utime' as a pointer to struct or as a 'u32'.

- In case it's used as a 'u32', it makes a copy of it,
  and of course it is not dereferenced.

- In case it's used as a 'struct __kernel_timespec __user *',
  the pointer is not dereferenced inside the futex() definition,
  and it is only passed to a function: get_timespec64(),
  which accepts a 'const struct __kernel_timespec __user *'.

context:
........

[[
FUTEX(2)               Linux Programmer's Manual              FUTEX(2)

NAME
       futex - fast user-space locking

SYNOPSIS
       #include <linux/futex.h>
       #include <stdint.h>
       #include <sys/time.h>

       long futex(uint32_t *uaddr, int futex_op, uint32_t val,
                 const struct timespec *timeout,   /* or: uint32_t val2 */
                 uint32_t *uaddr2, uint32_t val3);

       Note:  There  is  no  glibc  wrapper  for this system call; see
       NOTES.
]]

$ sed -n '/SYSCALL_DEFINE.(futex\>/,/^}/p' linux/kernel/futex.c
SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
		struct __kernel_timespec __user *, utime, u32 __user *, uaddr2,
		u32, val3)

70 more quoted lines

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es

Ping: [PATCH] futex: Change 'utime' parameter to be 'const ... *'

Message details and related content
Ping!

On 12/10/20 6:36 PM, Alejandro Colomar (man-pages) wrote:
Hi Thomas & Ingo,

I tested the changes. Everything's OK.

Cheers,

Alex

$ uname -a
Linux debian 5.10.0-rc7+alx3+ #4 SMP Thu Dec 10 18:05:03 CET 2020 x86_64
GNU/Linux

.../linux/tools/testing/selftests/futex$ sudo ./run.sh
[sudo] password for user:

TAP version 13
1..1
# futex_requeue_pi: Test requeue functionality
# 	Arguments: broadcast=0 locked=0 owner=0 timeout=0ns
ok 1 futex-requeue-pi
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
TAP version 13
1..1
# futex_requeue_pi: Test requeue functionality
# 	Arguments: broadcast=1 locked=0 owner=0 timeout=0ns
ok 1 futex-requeue-pi
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
TAP version 13
1..1
# futex_requeue_pi: Test requeue functionality
# 	Arguments: broadcast=1 locked=1 owner=0 timeout=0ns
ok 1 futex-requeue-pi
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
TAP version 13
1..1
# futex_requeue_pi: Test requeue functionality
# 	Arguments: broadcast=1 locked=0 owner=1 timeout=0ns
ok 1 futex-requeue-pi
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
TAP version 13

248 more quoted lines

Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help