Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1991440imn; Mon, 1 Aug 2022 07:22:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6qMcFrQrxeI3FOaM4q4X1X0kXkeQjlRpVKSB9FoBK7PBGNiIsGAxlSnMo+LxIlGop39Vxg X-Received: by 2002:a17:906:9beb:b0:730:8e6c:a8fa with SMTP id de43-20020a1709069beb00b007308e6ca8famr2952433ejc.258.1659363752806; Mon, 01 Aug 2022 07:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659363752; cv=none; d=google.com; s=arc-20160816; b=hFQiKWG0CqhUfSkhVhe3ILhcrh7b4OYcnXLhy4KDvxWzSBoJdnPiUrQRAEXhcjQNVH A9xE8VoE41NEzci0Ak33rB+eAj/gagdXCCwlGrf+lUpokkJwDHQeHeuYOxqIaWdTsJKb Hq5rA00+LGJes6nPlumLqXhOjGJrGzmB498uctfgc2gV4xChL/MYdRxgBDXn6hAXYK1c oHQq/AL9GYjSgYQl7HHvDn2XY4uFcGQxMZYuPl0syhsrda2ksGdSlH6/4c7Ih7Wdjg4w v+XYS8NCD7l4f0Rv+qZUgl/TJKT+g4yFtXo0h6m3SzlbIfbW/j/TtKLUxd+6B1F3+q3A zJUg== 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=sHXy2YTofn+Ct+amiEKkOUOnH9OzAMcdg5/V6z2J7CM=; b=GRyFO92B0CKxGBCphKhbWm8xht5O5YMZ6k5pI8LwBL1L/+fCCNFo8+TZEEdfLa+IKC vT4RwUxzqmTdakHUZHIaFE2ulrPY7uW4adNXj+usRmXrcYykOHEtVjD0jSuOGNfCypAi 3Ns+PWY22DCre3G7UymMVf538ymvxevWp0t7fieD/0rcPcyeCM85coVfQ1gS1EPlmXxg UYQfLaWMFp0cgZL0IneWcBRfPogLAwWo+qt8hvTlMP6ZzCDpLLjlltYffyM9XX1ux7zK al8T1fnHXmxWPmZDP8qfOg9YaUYwAKSP7uHO5BF53Ss6E9Hs/PmGDAwP9LRjQIKgujhi Hj1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="p23dA/z+"; dkim=neutral (no key) header.i=@linutronix.de; 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 cs18-20020a170906dc9200b0072fc5a78f82si3313852ejc.202.2022.08.01.07.22.02; Mon, 01 Aug 2022 07:22:32 -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="p23dA/z+"; dkim=neutral (no key) header.i=@linutronix.de; 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 S231488AbiHANZ4 (ORCPT + 99 others); Mon, 1 Aug 2022 09:25:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231496AbiHANZn (ORCPT ); Mon, 1 Aug 2022 09:25:43 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79D4739B94; Mon, 1 Aug 2022 06:25:42 -0700 (PDT) Date: Mon, 01 Aug 2022 13:25:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1659360341; 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=sHXy2YTofn+Ct+amiEKkOUOnH9OzAMcdg5/V6z2J7CM=; b=p23dA/z+WQIum3kOXmP55zCS139Fh5veWQzNK3EiDAN0blqpo6pC3DIdlqXpmVgAqVf1vF eghEqbReyehaAO3sJK/dGpj5W594H2l767oHOIEmO5a6UGuOj5tXxVn7B8q1v3fGHKBHD+ QzWuBVIDc1YstNRvDz2ETqSdstOrkI6zIjwyOBYtO/ZEckHMJO7DjK8/rU7865LE+JAe52 oJirlSXZO5TnXtmXPk0ro3VXL5A8Upzsz1X+XtkhZG6G7iFz0MflL7zUTZXzvmU5XplupW 01SxFSx+Jm5nRkNgsqnznGv8/t/KQdNPPqzSo7ZqflJfHpTW+LzEA6cfA/t0Ag== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1659360341; 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=sHXy2YTofn+Ct+amiEKkOUOnH9OzAMcdg5/V6z2J7CM=; b=8fOVn3n4bGOH5YkK74kus9Tay8+rgw0ttxfe3xmvVAqMBchHr32vPc+TnJnU5gOwtiFyDX vt/SlwRtujmXwCCQ== 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)" , Ingo Molnar , 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: <165936033979.15455.14072233165429721291.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: 0190e4198e47fe99d002d72588f34fd62c9ab570 Gitweb: https://git.kernel.org/tip/0190e4198e47fe99d002d72588f34fd62c9ab570 Author: Mathieu Desnoyers AuthorDate: Wed, 22 Jun 2022 15:46:16 -04:00 Committer: Ingo Molnar CommitterDate: Mon, 01 Aug 2022 15:21:29 +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) Signed-off-by: Ingo Molnar 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)