From patchwork Thu Sep 21 17:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 142954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5172296vqi; Thu, 21 Sep 2023 15:15:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1ntt0+R0wEtNMcubmP/ePEdIqIqzArqY2dmrYfb528aZ+ELTCpF0zCGD0ZTQnfSFNc/BZ X-Received: by 2002:a05:6358:291f:b0:13a:319f:a56b with SMTP id y31-20020a056358291f00b0013a319fa56bmr7603477rwb.20.1695334503285; Thu, 21 Sep 2023 15:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695334503; cv=none; d=google.com; s=arc-20160816; b=KZrX/msAP8ofDdfuYsrHK9wcbhbtndDob/E/oJQSbs6MbDIGUw1M177XzqPVtZCDd+ 5osqV6/fFOfh6AKfOPZ9GOfyDQ7U3KlBitr8AlvNinGR7YXuU1FLYRu0NdaZaU5PnsDh iBy4OeDUV4PS/4vj355whCMoarL30VFpo/XkQZb7JRoMfwex0i+WTl02AETXJOHZARmA A8fxRXG6K7TtatSUlBKFi48DbRwo659Zwhd99a7YVg81XTzAbB+p8GxzW55kYJ8KQJh7 IhlB3HOiOoBB2pAlF8+yh1lBMBOKAGvxdrN5m4fRKh/EiwhJFcWVWA0oYl0stFiyoloD zlnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=I0XoGbkGrsY9M6VIGn5Woc8BmhyjnaFTf3yO8yqiAIE=; fh=51w4OSdjTJF7zPLz9BeYfqokcBXCUA1NOZqhQDttTbc=; b=adwA4rhVjQRl1oOrdVUvWgLu8iwIniTzroffk64M2iThiErULY+J9riHvITDVjX28c SiCaMiUDUUuYwDhZ5IyrstRk6xg+TdEZUsWxHBMk5RZXDyUsN26WUKHlDfoTNrPUqJCG 1Oabu44REHk/BU5X8xoKGdvhAMabX7tMIoP/xncbo5dOgcjBLUX3+YQbpCoaPhE3y39v xiKrK92ZxsF/NhmpQdAaptT7++7R7TTLwyHNzC72RQOFW9uGGvMfimrJZLZn09TXC2By V+FM7TWQtM2zqRpZrZsc3NVWRBa7ydFr/k1v9AZ92qxEikFgcfzmFWdqM7m6/rTjTO/I /0GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wOAtrnWd; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id l192-20020a633ec9000000b005741597ab7fsi960242pga.96.2023.09.21.15.15.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 15:15:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wOAtrnWd; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id DDE558038B36; Thu, 21 Sep 2023 13:47:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231975AbjIUUrh (ORCPT + 29 others); Thu, 21 Sep 2023 16:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232201AbjIUUrK (ORCPT ); Thu, 21 Sep 2023 16:47:10 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D441381FFF; Thu, 21 Sep 2023 10:36:34 -0700 (PDT) Date: Thu, 21 Sep 2023 17:36:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695317766; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=I0XoGbkGrsY9M6VIGn5Woc8BmhyjnaFTf3yO8yqiAIE=; b=wOAtrnWd+R4t5aeicoFBajsnsFHm5Z7QMJwzru54qLoG9ZXN4AhafxTuy0VkV6hJv4t9ef T7qCHxQX/HK6aP3Z5w1jrYEF2oq8coSaa0IoiwbM7mgwtdsQSfLHTZ3vf5Yv3zC1A9PU5I sYnJtOdM9ueLUCnQCWQnZWnfCIuFs6dYSMRJS+W9WklPaKj630uwD9ZvKThzTOdfuKidcQ ZxHbL6WfuZHvZNcouwoPeQ7hR5YJfJCgc/3+EPtb1oRR1+8BXuJL7w+jy0RS3sWWfJ+s6x t1b36INQ1y+WOuPa0GyWMnMozDQB6ZJEczJt13ulWzBwCm9adz+UMeQghrJ6UA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695317766; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=I0XoGbkGrsY9M6VIGn5Woc8BmhyjnaFTf3yO8yqiAIE=; b=P5QojkC5fuE535hqBbwK/cDMTLlvbXjxLS+29iyV/Cfw+hgtj0qLJSG26rQYORBRMVYCIQ 1OuKi0XuMJtwGQDw== From: "tip-bot2 for peterz@infradead.org" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] futex: Extend the FUTEX2 flags Cc: "Peter Zijlstra (Intel)" , Thomas Gleixner , andrealmeid@igalia.com, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230921105247.617057368@noisy.programming.kicks-ass.net> References: <20230921105247.617057368@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Message-ID: <169531776622.27769.3661853983494438744.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:47:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777687071728968918 X-GMAIL-MSGID: 1777687071728968918 The following commit has been merged into the locking/core branch of tip: Commit-ID: d6d08d24790e82c69a46ef78ae44fe1b1ed30775 Gitweb: https://git.kernel.org/tip/d6d08d24790e82c69a46ef78ae44fe1b1ed30775 Author: peterz@infradead.org AuthorDate: Thu, 21 Sep 2023 12:45:07 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 21 Sep 2023 19:22:05 +02:00 futex: Extend the FUTEX2 flags Add the definition for the missing but always intended extra sizes, and add a NUMA flag for the planned numa extention. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Thomas Gleixner Reviewed-by: André Almeida Link: https://lore.kernel.org/r/20230921105247.617057368@noisy.programming.kicks-ass.net --- include/uapi/linux/futex.h | 21 ++++++++++++++++++--- kernel/futex/syscalls.c | 9 +++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h index 21d4eff..d2ee625 100644 --- a/include/uapi/linux/futex.h +++ b/include/uapi/linux/futex.h @@ -45,17 +45,32 @@ /* * Flags for futex2 syscalls. + * + * NOTE: these are not pure flags, they can also be seen as: + * + * union { + * u32 flags; + * struct { + * u32 size : 2, + * numa : 1, + * : 4, + * private : 1; + * }; + * }; */ - /* 0x00 */ - /* 0x01 */ +#define FUTEX2_SIZE_U8 0x00 +#define FUTEX2_SIZE_U16 0x01 #define FUTEX2_SIZE_U32 0x02 - /* 0x04 */ +#define FUTEX2_SIZE_U64 0x03 +#define FUTEX2_NUMA 0x04 /* 0x08 */ /* 0x10 */ /* 0x20 */ /* 0x40 */ #define FUTEX2_PRIVATE FUTEX_PRIVATE_FLAG +#define FUTEX2_SIZE_MASK 0x03 + /* do not use */ #define FUTEX_32 FUTEX2_SIZE_U32 /* historical accident :-( */ diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c index ff696b0..953f0a4 100644 --- a/kernel/futex/syscalls.c +++ b/kernel/futex/syscalls.c @@ -183,7 +183,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, return do_futex(uaddr, op, val, tp, uaddr2, (unsigned long)utime, val3); } -#define FUTEX2_VALID_MASK (FUTEX2_SIZE_U32 | FUTEX2_PRIVATE) +#define FUTEX2_VALID_MASK (FUTEX2_SIZE_MASK | FUTEX2_PRIVATE) /** * futex_parse_waitv - Parse a waitv array from userspace @@ -207,7 +207,12 @@ static int futex_parse_waitv(struct futex_vector *futexv, if ((aux.flags & ~FUTEX2_VALID_MASK) || aux.__reserved) return -EINVAL; - if (!(aux.flags & FUTEX2_SIZE_U32)) + if (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall()) { + if ((aux.flags & FUTEX2_SIZE_MASK) == FUTEX2_SIZE_U64) + return -EINVAL; + } + + if ((aux.flags & FUTEX2_SIZE_MASK) != FUTEX2_SIZE_U32) return -EINVAL; futexv[i].w.flags = aux.flags;