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

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/futex.c+5−0
@@ -39,6 +39,7 @@ · 38 unmodified lines
39#include <linux/freezer.h>39#include <linux/freezer.h>
40#include <linux/memblock.h>40#include <linux/memblock.h>
41#include <linux/fault-inject.h>41#include <linux/fault-inject.h>
42#include <linux/time_namespace.h>
42 43
43#include <asm/futex.h>44#include <asm/futex.h>
44 45
@@ -3797,6 +3798,8 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, · 3752 unmodified lines
3797 t = timespec64_to_ktime(ts);3798 t = timespec64_to_ktime(ts);
3798 if (cmd == FUTEX_WAIT)3799 if (cmd == FUTEX_WAIT)
3799 t = ktime_add_safe(ktime_get(), t);3800 t = ktime_add_safe(ktime_get(), t);
3801 else if (!(op & FUTEX_CLOCK_REALTIME))
3802 t = timens_ktime_to_host(CLOCK_MONOTONIC, t);
3800 tp = &t;3803 tp = &t;
3801 }3804 }
3802 /*3805 /*
@@ -3989,6 +3992,8 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val, · 186 unmodified lines
3989 t = timespec64_to_ktime(ts);3992 t = timespec64_to_ktime(ts);
3990 if (cmd == FUTEX_WAIT)3993 if (cmd == FUTEX_WAIT)
3991 t = ktime_add_safe(ktime_get(), t);3994 t = ktime_add_safe(ktime_get(), t);
3995 else if (!(op & FUTEX_CLOCK_REALTIME))
3996 t = timens_ktime_to_host(CLOCK_MONOTONIC, t);
3992 tp = &t;3997 tp = &t;
3993 }3998 }
3994 if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE ||3999 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