* [patch 1/6] Revert 337f13046ff0 ("futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op") [not found] <20210422194417.866740847@linutronix.de> @ 2021-04-22 19:44 ` Thomas Gleixner 2021-05-06 18:14 ` [tip: locking/urgent] " tip-bot2 for Thomas Gleixner 2021-04-22 19:44 ` [patch 2/6] futex: Do not apply time namespace adjustment on FUTEX_LOCK_PI Thomas Gleixner 1 sibling, 1 reply; 4+ messages in thread From: Thomas Gleixner @ 2021-04-22 19:44 UTC (permalink / raw) To: LKML Cc: Peter Zijlstra, Adhemerval Zanella, Lukasz Majewski, Florian Weimer, Carlos O'Donell, Michael Kerrisk (man-pages), Davidlohr Bueso, Ingo Molnar, stable, Darren Hart, Andrei Vagin, Kurt Kanzenbach The FUTEX_WAIT operand has historically a relative timeout which means that the clock id is irrelevant as relative timeouts on CLOCK_REALTIME are not subject to wall clock changes and therefore are mapped by the kernel to CLOCK_MONOTONIC for simplicity. If a caller would set FUTEX_CLOCK_REALTIME for FUTEX_WAIT the timeout is still treated relative vs. CLOCK_MONOTONIC and then the wait arms that timeout based on CLOCK_REALTIME which is broken and obviously has never been used or even tested. Reject any attempt to use FUTEX_CLOCK_REALTIME with FUTEX_WAIT again. The desired functionality can be achieved with FUTEX_WAIT_BITSET and a FUTEX_BITSET_MATCH_ANY argument. Fixes: 337f13046ff0 ("futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op") Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: stable@vger.kernel.org Cc: Darren Hart <dvhart@infradead.org> --- kernel/futex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -3711,8 +3711,7 @@ long do_futex(u32 __user *uaddr, int op, if (op & FUTEX_CLOCK_REALTIME) { flags |= FLAGS_CLOCKRT; - if (cmd != FUTEX_WAIT && cmd != FUTEX_WAIT_BITSET && \ - cmd != FUTEX_WAIT_REQUEUE_PI) + if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI) return -ENOSYS; } ^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: locking/urgent] Revert 337f13046ff0 ("futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op") 2021-04-22 19:44 ` [patch 1/6] Revert 337f13046ff0 ("futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op") Thomas Gleixner @ 2021-05-06 18:14 ` tip-bot2 for Thomas Gleixner 0 siblings, 0 replies; 4+ messages in thread From: tip-bot2 for Thomas Gleixner @ 2021-05-06 18:14 UTC (permalink / raw) To: linux-tip-commits Cc: Thomas Gleixner, Peter Zijlstra (Intel), stable, x86, linux-kernel The following commit has been merged into the locking/urgent branch of tip: Commit-ID: 4fbf5d6837bf81fd7a27d771358f4ee6c4f243f8 Gitweb: https://git.kernel.org/tip/4fbf5d6837bf81fd7a27d771358f4ee6c4f243f8 Author: Thomas Gleixner <tglx@linutronix.de> AuthorDate: Thu, 22 Apr 2021 21:44:18 +02:00 Committer: Thomas Gleixner <tglx@linutronix.de> CommitterDate: Thu, 06 May 2021 20:12:40 +02:00 Revert 337f13046ff0 ("futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op") The FUTEX_WAIT operand has historically a relative timeout which means that the clock id is irrelevant as relative timeouts on CLOCK_REALTIME are not subject to wall clock changes and therefore are mapped by the kernel to CLOCK_MONOTONIC for simplicity. If a caller would set FUTEX_CLOCK_REALTIME for FUTEX_WAIT the timeout is still treated relative vs. CLOCK_MONOTONIC and then the wait arms that timeout based on CLOCK_REALTIME which is broken and obviously has never been used or even tested. Reject any attempt to use FUTEX_CLOCK_REALTIME with FUTEX_WAIT again. The desired functionality can be achieved with FUTEX_WAIT_BITSET and a FUTEX_BITSET_MATCH_ANY argument. Fixes: 337f13046ff0 ("futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op") Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210422194704.834797921@linutronix.de --- kernel/futex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index c98b825..4740200 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -3710,8 +3710,7 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, if (op & FUTEX_CLOCK_REALTIME) { flags |= FLAGS_CLOCKRT; - if (cmd != FUTEX_WAIT && cmd != FUTEX_WAIT_BITSET && \ - cmd != FUTEX_WAIT_REQUEUE_PI) + if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI) return -ENOSYS; } ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [patch 2/6] futex: Do not apply time namespace adjustment on FUTEX_LOCK_PI [not found] <20210422194417.866740847@linutronix.de> 2021-04-22 19:44 ` [patch 1/6] Revert 337f13046ff0 ("futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op") Thomas Gleixner @ 2021-04-22 19:44 ` Thomas Gleixner 2021-05-06 18:14 ` [tip: locking/urgent] " tip-bot2 for Thomas Gleixner 1 sibling, 1 reply; 4+ messages in thread From: Thomas Gleixner @ 2021-04-22 19:44 UTC (permalink / raw) To: LKML Cc: Peter Zijlstra, Adhemerval Zanella, Lukasz Majewski, Florian Weimer, Carlos O'Donell, Michael Kerrisk (man-pages), Davidlohr Bueso, Ingo Molnar, Andrei Vagin, stable, Darren Hart, Kurt Kanzenbach FUTEX_LOCK_PI does not require to have the FUTEX_CLOCK_REALTIME bit set because it has been using CLOCK_REALTIME based absolute timeouts forever. Due to that, the time namespace adjustment which is applied when FUTEX_CLOCK_REALTIME is not set, will wrongly take place for FUTEX_LOCK_PI and wreckage the timeout. Exclude it from that procedure. Fixes: c2f7d08cccf4 ("futex: Adjust absolute futex timeouts with per time namespace offset") Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andrei Vagin <avagin@gmail.com> Cc: stable@vger.kernel.org --- kernel/futex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -3781,7 +3781,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uad t = timespec64_to_ktime(ts); if (cmd == FUTEX_WAIT) t = ktime_add_safe(ktime_get(), t); - else if (!(op & FUTEX_CLOCK_REALTIME)) + else if (cmd != FUTEX_LOCK_PI && !(op & FUTEX_CLOCK_REALTIME)) t = timens_ktime_to_host(CLOCK_MONOTONIC, t); tp = &t; } @@ -3975,7 +3975,7 @@ SYSCALL_DEFINE6(futex_time32, u32 __user t = timespec64_to_ktime(ts); if (cmd == FUTEX_WAIT) t = ktime_add_safe(ktime_get(), t); - else if (!(op & FUTEX_CLOCK_REALTIME)) + else if (cmd != FUTEX_LOCK_PI && !(op & FUTEX_CLOCK_REALTIME)) t = timens_ktime_to_host(CLOCK_MONOTONIC, t); tp = &t; } ^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: locking/urgent] futex: Do not apply time namespace adjustment on FUTEX_LOCK_PI 2021-04-22 19:44 ` [patch 2/6] futex: Do not apply time namespace adjustment on FUTEX_LOCK_PI Thomas Gleixner @ 2021-05-06 18:14 ` tip-bot2 for Thomas Gleixner 0 siblings, 0 replies; 4+ messages in thread From: tip-bot2 for Thomas Gleixner @ 2021-05-06 18:14 UTC (permalink / raw) To: linux-tip-commits Cc: Thomas Gleixner, Peter Zijlstra (Intel), stable, x86, linux-kernel The following commit has been merged into the locking/urgent branch of tip: Commit-ID: cdf78db4070967869e4d027c11f4dd825d8f815a Gitweb: https://git.kernel.org/tip/cdf78db4070967869e4d027c11f4dd825d8f815a Author: Thomas Gleixner <tglx@linutronix.de> AuthorDate: Thu, 22 Apr 2021 21:44:19 +02:00 Committer: Thomas Gleixner <tglx@linutronix.de> CommitterDate: Thu, 06 May 2021 20:12:40 +02:00 futex: Do not apply time namespace adjustment on FUTEX_LOCK_PI FUTEX_LOCK_PI does not require to have the FUTEX_CLOCK_REALTIME bit set because it has been using CLOCK_REALTIME based absolute timeouts forever. Due to that, the time namespace adjustment which is applied when FUTEX_CLOCK_REALTIME is not set, will wrongly take place for FUTEX_LOCK_PI and wreckage the timeout. Exclude it from that procedure. Fixes: c2f7d08cccf4 ("futex: Adjust absolute futex timeouts with per time namespace offset") Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210422194704.984540159@linutronix.de --- kernel/futex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 4740200..b0f5304 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -3780,7 +3780,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, t = timespec64_to_ktime(ts); if (cmd == FUTEX_WAIT) t = ktime_add_safe(ktime_get(), t); - else if (!(op & FUTEX_CLOCK_REALTIME)) + else if (cmd != FUTEX_LOCK_PI && !(op & FUTEX_CLOCK_REALTIME)) t = timens_ktime_to_host(CLOCK_MONOTONIC, t); tp = &t; } @@ -3974,7 +3974,7 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val, t = timespec64_to_ktime(ts); if (cmd == FUTEX_WAIT) t = ktime_add_safe(ktime_get(), t); - else if (!(op & FUTEX_CLOCK_REALTIME)) + else if (cmd != FUTEX_LOCK_PI && !(op & FUTEX_CLOCK_REALTIME)) t = timens_ktime_to_host(CLOCK_MONOTONIC, t); tp = &t; } ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-06 18:14 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20210422194417.866740847@linutronix.de> 2021-04-22 19:44 ` [patch 1/6] Revert 337f13046ff0 ("futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op") Thomas Gleixner 2021-05-06 18:14 ` [tip: locking/urgent] " tip-bot2 for Thomas Gleixner 2021-04-22 19:44 ` [patch 2/6] futex: Do not apply time namespace adjustment on FUTEX_LOCK_PI Thomas Gleixner 2021-05-06 18:14 ` [tip: locking/urgent] " tip-bot2 for Thomas Gleixner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).