Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp752907imn; Sat, 30 Jul 2022 01:27:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sJczIaifqLLtYegk1kHGukcag++43St6rgobqkjGJ1p/ILe9Z63VPPtqxYFIn2STMteQar X-Received: by 2002:a17:907:96a8:b0:72b:40b0:658 with SMTP id hd40-20020a17090796a800b0072b40b00658mr5583582ejc.3.1659169629793; Sat, 30 Jul 2022 01:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659169629; cv=none; d=google.com; s=arc-20160816; b=e4pLDMMdyX/RRYVnAgotXDWsC3GICs2hgbNgPXj7SLl5DLEZvCz55yswgLhpt8XcbU Bzabd0LdnYeT8OnrZhB+v8Z2gbIyEEw+hQv7SvDVaAokK2I0geCZy3ioAKQbXl2/eFh8 Z+O+jUPRJ21l1lbGeCSW7XZhoTNRfj/PA9ThdDMZeC1mo+irxyMH5KGUQJQ0cgmLKnuq UZPmp0ifH+dIcke9VWoxuJdyDMOiN5WYTwhgb8B3QmMLuEVR7Djn1K8qvyGr6pD8FDOM 6E8si/il7UvTM2KTucOkQ+TwjQ99s9IDyc88W93hEQuuKOc5jN4PICdh2OLyVUoXW/k7 u7IA== 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=5GRmTVsZ8q987tdymI6cdzIGtqdzCcKVr7InVX396Ek=; b=amtU4AN2Fmuki6hgYHNCjE0ubFG7U3qx4z5XqWbvQRukOsGdG73k9C+pgApGkmBkxl arEB1BtYmZJp+/YYXI7GtCiI6o+MPB2luNfvmHIFykJo4abrnyiodjGAXHjMV+JYIhJE QtQP1etxOlZN6BeKm8QeqW2VU6Kp7AwIYoV9PybPLI1L3+dFESY8fq3GEpvuP8Oh9F/o p0Q/vtCfGH4HU812dbd2+0XNwtI+kXJgqNaK+DZzGtz0Z4vuBneUpt1aYYRdXB1gUYOd WEC8UtQHMkO6Qho6cGAO305rX3jWwbteuPklLa5X4LKzOAdla2KotSMWQAdO57S3CHEe exNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YVkcofyP; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn17-20020a17090794d100b0072fb5360020si571076ejc.518.2022.07.30.01.26.45; Sat, 30 Jul 2022 01:27:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YVkcofyP; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231610AbiG3IVs (ORCPT + 99 others); Sat, 30 Jul 2022 04:21:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbiG3IVr (ORCPT ); Sat, 30 Jul 2022 04:21:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB943240B3; Sat, 30 Jul 2022 01:21:44 -0700 (PDT) Date: Sat, 30 Jul 2022 08:21:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1659169303; 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=5GRmTVsZ8q987tdymI6cdzIGtqdzCcKVr7InVX396Ek=; b=YVkcofyPDERULFyhQsaiSRd3P+Vn+lkgBFNE2o7tl/vxwe3NMcN/CIn9C7FUoDFDIjH+pD EaCtQ913eKvnFXB61gEmUlNXjLWWdNJ7LsmxduNuLqVNmlbbZRiAbraUzmovPo6IQrk61N EFSe5XtgY2oraM2Q03AKhnFlAiAv03Lmne8PtMeANkD533I0YBWL7MYWnLKwKH545ljHaX WbrM6e3gw14I2Z4872z6TC4mpAKrVWbkyWJTUPSwd0yKrjYl88IweIriEDIGNMWshm1ioN NoJ/C+4U4qA5MJNHYHZ5b1HcPb5VgxQuaZ6Rtn9jV3LKXnrtr+O1n6SzjOKpOw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1659169303; 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=5GRmTVsZ8q987tdymI6cdzIGtqdzCcKVr7InVX396Ek=; b=tvy6kG8q3n3kRRKOiw7E8d5XjoXAO6So11zzVIaT4Uogazelm+XbunT5FTTEs35w+prQOD /6IAF6gbw5OPdBBw== From: "tip-bot2 for Mathieu Desnoyers" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] rseq: Deprecate RSEQ_CS_FLAG_NO_RESTART_ON_* flags Cc: Mathieu Desnoyers , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220622194617.1155957-1-mathieu.desnoyers@efficios.com> References: <20220622194617.1155957-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Message-ID: <165916930174.15455.14411545182545206079.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: c040fc3cb4ce18e1be54df6294f6a4004d2664ec Gitweb: https://git.kernel.org/tip/c040fc3cb4ce18e1be54df6294f6a4004d2664ec Author: Mathieu Desnoyers AuthorDate: Wed, 22 Jun 2022 15:46:16 -04:00 Committer: Peter Zijlstra CommitterDate: Sat, 30 Jul 2022 10:14:18 +02:00 rseq: Deprecate RSEQ_CS_FLAG_NO_RESTART_ON_* flags The pretty much unused RSEQ_CS_FLAG_NO_RESTART_ON_* flags introduce complexity in rseq, and are subtly buggy [1]. Solving those issues requires introducing additional complexity in the rseq implementation for each supported architecture. Considering that it complexifies the rseq ABI, I am proposing that we deprecate those flags. [2] So far there appears to be consensus from maintainers of user-space projects impacted by this feature that its removal would be a welcome simplification. [3] The deprecation approach proposed here is to issue WARN_ON_ONCE() when encountering those flags and kill the offending process with sigsegv. This should allow us to quickly identify whether anyone yells at us for removing this. Link: https://lore.kernel.org/lkml/20220618182515.95831-1-minhquangbui99@gmail.com/ [1] Link: https://lore.kernel.org/lkml/258546133.12151.1655739550814.JavaMail.zimbra@efficios.com/ [2] Link: https://lore.kernel.org/lkml/87pmj1enjh.fsf@email.froward.int.ebiederm.org/ [3] Signed-off-by: Mathieu Desnoyers Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/lkml/20220622194617.1155957-1-mathieu.desnoyers@efficios.com --- kernel/rseq.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/kernel/rseq.c b/kernel/rseq.c index 97ac20b..81d7dc8 100644 --- a/kernel/rseq.c +++ b/kernel/rseq.c @@ -18,8 +18,9 @@ #define CREATE_TRACE_POINTS #include -#define RSEQ_CS_PREEMPT_MIGRATE_FLAGS (RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE | \ - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT) +#define RSEQ_CS_NO_RESTART_FLAGS (RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT | \ + RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL | \ + RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE) /* * @@ -175,23 +176,15 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags) u32 flags, event_mask; int ret; + if (WARN_ON_ONCE(cs_flags & RSEQ_CS_NO_RESTART_FLAGS)) + return -EINVAL; + /* Get thread flags. */ ret = get_user(flags, &t->rseq->flags); if (ret) return ret; - /* Take critical section flags into account. */ - flags |= cs_flags; - - /* - * Restart on signal can only be inhibited when restart on - * preempt and restart on migrate are inhibited too. Otherwise, - * a preempted signal handler could fail to restart the prior - * execution context on sigreturn. - */ - if (unlikely((flags & RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL) && - (flags & RSEQ_CS_PREEMPT_MIGRATE_FLAGS) != - RSEQ_CS_PREEMPT_MIGRATE_FLAGS)) + if (WARN_ON_ONCE(flags & RSEQ_CS_NO_RESTART_FLAGS)) return -EINVAL; /* @@ -203,7 +196,7 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags) t->rseq_event_mask = 0; preempt_enable(); - return !!(event_mask & ~flags); + return !!event_mask; } static int clear_rseq_cs(struct task_struct *t)