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.
Unified · Split
| @@ -39,6 +39,7 @@ · 38 unmodified lines | ||
| 39 | 39 | #include <linux/freezer.h> |
| 40 | 40 | #include <linux/memblock.h> |
| 41 | 41 | #include <linux/fault-inject.h> |
| 42 | +#include <linux/time_namespace.h> | |
| 42 | 43 | |
| 43 | 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 | 3798 | t = timespec64_to_ktime(ts); |
| 3798 | 3799 | if (cmd == FUTEX_WAIT) |
| 3799 | 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 | 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 | 3992 | t = timespec64_to_ktime(ts); |
| 3990 | 3993 | if (cmd == FUTEX_WAIT) |
| 3991 | 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 | 3997 | tp = &t; |
| 3993 | 3998 | } |
| 3994 | 3999 | if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || |