From patchwork Thu Apr 22 19:44:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 426805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1022EC433B4 for ; Thu, 22 Apr 2021 20:29:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D534F61422 for ; Thu, 22 Apr 2021 20:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237077AbhDVUaO (ORCPT ); Thu, 22 Apr 2021 16:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236993AbhDVUaO (ORCPT ); Thu, 22 Apr 2021 16:30:14 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6E83C06174A; Thu, 22 Apr 2021 13:29:37 -0700 (PDT) Message-Id: <20210422194704.984540159@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1619123376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=QEWkB2rFEnM13X0FKJCpTSym3PN7/+G4+71WvlUWCtA=; b=uFb7FlfaNL0gOPm575cXhBZ88RrS2C+xAlB8nEeTZuq8E9IL4rD4yeGlSZzxTR6zTWCZfw xfYAVsCB4RqqUj9FImlylaujjPfHc52S3euiCBDmMpQzO33hR/xXMri+4NmwWFpFd1LX8Z lBAZ2zChAFaUB4qkyOE+UJEZ6cPBpFO9MQgTtz5Z5Qkb9jYwrfkszzO+3szjOKZ23c2sbc NWmt/6e0R/GPuSWLM13DpHf1IziEoxFlqRgZFX/KfLTJPc9KBBWuKAHtgVf8TsVDtlofTA roWPMHAEK3V/OmVeLBU2Dqbf/PwdRGbyCVoEfw1/+XmTLI5umSDDpUBIhI2yKA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1619123376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=QEWkB2rFEnM13X0FKJCpTSym3PN7/+G4+71WvlUWCtA=; b=4aNt+FsOh9RSDz7T2IdicANpZT/2g1QIy9US8nKK13cGT6fxJ7aDfXGvB7yBNQIBXQ8xzM XzF40T5MgbI4A4CQ== Date: Thu, 22 Apr 2021 21:44:19 +0200 From: Thomas Gleixner 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@vger.kernel.org, Darren Hart , Kurt Kanzenbach Subject: [patch 2/6] futex: Do not apply time namespace adjustment on FUTEX_LOCK_PI References: <20210422194417.866740847@linutronix.de> MIME-Version: 1.0 Content-transfer-encoding: 8-bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 Cc: Andrei Vagin 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; }