Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp788900pxy; Thu, 22 Apr 2021 13:31:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmMe+MXSnUdKoinSnW5abpu0KIt+65lbRKVAyoZlBs0Tnx24IaXnHe1MOQzrgkfPWrhQaG X-Received: by 2002:aa7:dc46:: with SMTP id g6mr355265edu.342.1619123483826; Thu, 22 Apr 2021 13:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619123483; cv=none; d=google.com; s=arc-20160816; b=Z/goc9vexBkkSmCAq4r60guPlbCGzdty9pRUQb8plTZ45yw0eF2uoXAykPDT5VGV2Y u2U2LQGUJl9ngpDbaPCMIAqKunFhAjQLYMiK8N1WOzqQMWIQhNcaK7AzIUgHq9jPcaVQ F/LwWzSX95J0pDnGfxd9n1thNsqrzARsCPrez5VWJXDmTpLb0/rEulZdbGmrzveg/BGI dSaTU1Lkbd6kkmjRhsyrnasu+QzX/yzqTkEwbCVaXVcrEXtUHsX9jVcu07bFXCT+zl/q T4/Jk+SQZPYb1F2LqRwceGPRJXw7qTisyBLy1BEhZDFeYfXjhs5SBO5JFajyebKZP/H+ YQGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:subject:cc:to:from:date:dkim-signature:dkim-signature :message-id; bh=5+Nf1hNa8uJgYIBeiJzmvWEoEyrCLxbp2wWmMTt1B5E=; b=NkjjsJELcfi5SX1WSiWtHypI4xvVhuKWnRGeJ7qv2+Gm0fBQK0ypvgi4llfnn/TxK6 lnlS35S7sjSi8UJQPowARLvbtbKsL7hMY6fJaTVhCthlxRZjdDgfXAI70sTZ6yi9M0Oq V14yUHkl9VKH9rBJ6FkH+fTRxKKMVkohXEzRNVd6wesBhaPPvcyh7M3Z3V7xTNRyrm3+ DSiRx0NHr3Z/9FBvlk2836AIiRAUlPlc7GuVtgMN3Dt8CKwpBfXk+qJdjj/eA61GZ01b bYatuszVw2YKir4TmRwIKhlls86Ojk37VS+ubnxr4g04nbYEBmdNE+RZIIFg+bXwXeNE bd3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kkm9ZaR6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SgbsvqcS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i26si2899525ejc.496.2021.04.22.13.31.00; Thu, 22 Apr 2021 13:31:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kkm9ZaR6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SgbsvqcS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239383AbhDVUaV (ORCPT + 99 others); Thu, 22 Apr 2021 16:30:21 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:41016 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239216AbhDVUaP (ORCPT ); Thu, 22 Apr 2021 16:30:15 -0400 Message-Id: <20210422194705.338657741@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1619123380; 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=5+Nf1hNa8uJgYIBeiJzmvWEoEyrCLxbp2wWmMTt1B5E=; b=kkm9ZaR6/SglwS9pc47PYBaPxO96kTlv+XcH+dAxY4vmWsUv3IM1xr+wBKfOAiqmO8VWmi Rv50In9QyvMh5KOZWtE4bqeGKZcqJWeXKCZ8qNEDqIUWpMoFCmVW5gZUOhU9/0qHb9WG2b HpzhN9G4D5gKG4kIh7EB0KOQe4DNdYmka/e6VgFHb1IPwCzORF3NhID+ZTw3hQ1Ao1Xr6/ 1CCpCtRcPxFMbPqDMM2RDYr3HkWZXqN+h7q0ypT8Z18YLjzngHpeCmZCLBH7vsWDdFiroH OcceFznxEx7wFMX1Wsxv1FG3F0yrJinUce9LNrRRmIM1A+UWwnW2ToPX/LWhCQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1619123380; 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=5+Nf1hNa8uJgYIBeiJzmvWEoEyrCLxbp2wWmMTt1B5E=; b=SgbsvqcSMq39dMe/uqpkdxZCkUs92FS0NSL3v4/GpDph7sLFpnsSsq6K8Ckl+MrhkTU1pu hCrpoaR+/J7cBaAA== Date: Thu, 22 Apr 2021 21:44:22 +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 , Kurt Kanzenbach , Darren Hart , Andrei Vagin Subject: [patch 5/6] futex: Prepare futex_lock_pi() for runtime clock selection References: <20210422194417.866740847@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-transfer-encoding: 8-bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org futex_lock_pi() is the only futex operation which cannot select the clock for timeouts (CLOCK_MONOTONIC/CLOCK_REALTIME). That's inconsistent and there is no particular reason why this cannot be supported. This was overlooked when CLOCK_REALTIME_FLAG was introduced and unfortunately not reported when the inconsistency was discovered in glibc. Prepare the function and enforce the CLOCK_REALTIME_FLAG on FUTEX_LOCK_PI so that a new FUTEX_LOCK_PI2 can implement it correctly. Reported-by: Kurt Kanzenbach Signed-off-by: Thomas Gleixner --- kernel/futex.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -2786,7 +2786,7 @@ static int futex_lock_pi(u32 __user *uad if (refill_pi_state_cache()) return -ENOMEM; - to = futex_setup_timer(time, &timeout, FLAGS_CLOCKRT, 0); + to = futex_setup_timer(time, &timeout, flags, 0); retry: ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key, FUTEX_WRITE); @@ -3711,7 +3711,7 @@ long do_futex(u32 __user *uaddr, int op, if (op & FUTEX_CLOCK_REALTIME) { flags |= FLAGS_CLOCKRT; - if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI) + if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI) return -ENOSYS; } @@ -3743,6 +3743,7 @@ long do_futex(u32 __user *uaddr, int op, case FUTEX_WAKE_OP: return futex_wake_op(uaddr, flags, uaddr2, val, val2, val3); case FUTEX_LOCK_PI: + flags |= FLAGS_CLOCKRT; return futex_lock_pi(uaddr, flags, timeout, 0); case FUTEX_UNLOCK_PI: return futex_unlock_pi(uaddr, flags);