History

futex: Adjust absolute futex timeouts with per time namespace offset

For all commands except FUTEX_WAIT, the timeout is interpreted as an absolute value. This absolute value is inside the task's time namespace and has to be converted to the host's time.

Andrei Vagin committed 6 years ago

Commit c2f7d081 parent 270315b1 file · +5 −0Browse files

Unified · Split

kernel/futex.c+5−0
@@ -39,6 +39,7 @@ · 38 unmodified lines
3939 #include <linux/freezer.h>
4040 #include <linux/memblock.h>
4141 #include <linux/fault-inject.h>
42+#include <linux/time_namespace.h>
4243
4344 #include <asm/futex.h>
4445
@@ -3797,6 +3798,8 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, · 3752 unmodified lines
37973798 t = timespec64_to_ktime(ts);
37983799 if (cmd == FUTEX_WAIT)
37993800 t = ktime_add_safe(ktime_get(), t);
3801+ else if (!(op & FUTEX_CLOCK_REALTIME))
3802+ t = timens_ktime_to_host(CLOCK_MONOTONIC, t);
38003803 tp = &t;
38013804 }
38023805 /*
@@ -3989,6 +3992,8 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val, · 186 unmodified lines
39893992 t = timespec64_to_ktime(ts);
39903993 if (cmd == FUTEX_WAIT)
39913994 t = ktime_add_safe(ktime_get(), t);
3995+ else if (!(op & FUTEX_CLOCK_REALTIME))
3996+ t = timens_ktime_to_host(CLOCK_MONOTONIC, t);
39923997 tp = &t;
39933998 }
39943999 if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE ||

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t