From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"Paul E . McKenney" <paulmck@kernel.org>,
Boqun Feng <boqun.feng@gmail.com>,
"H. Peter Anvin" <hpa@zytor.com>, Paul Turner <pjt@google.com>,
linux-api <linux-api@vger.kernel.org>,
Peter Oskolkov <posk@posk.io>
Subject: Re: [PATCH 1/2] rseq: Deprecate RSEQ_CS_FLAG_NO_RESTART_ON_* flags
Date: Tue, 26 Jul 2022 15:10:55 -0400 (EDT) [thread overview]
Message-ID: <790910676.83207.1658862655138.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20220622194617.1155957-1-mathieu.desnoyers@efficios.com>
----- On Jun 22, 2022, at 3:46 PM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote:
> 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.
Hi Peter, would you consider pulling this patch through the tip tree ?
Thanks,
Mathieu
>
> 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 <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 97ac20b4f738..81d7dc80787b 100644
> --- a/kernel/rseq.c
> +++ b/kernel/rseq.c
> @@ -18,8 +18,9 @@
> #define CREATE_TRACE_POINTS
> #include <trace/events/rseq.h>
>
> -#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)
> --
> 2.30.2
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
prev parent reply other threads:[~2022-07-26 19:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 19:46 [PATCH 1/2] rseq: Deprecate RSEQ_CS_FLAG_NO_RESTART_ON_* flags Mathieu Desnoyers
2022-06-22 19:46 ` [PATCH 2/2] rseq: Kill process when unknown flags are encountered in ABI structures Mathieu Desnoyers
2022-07-26 19:11 ` Mathieu Desnoyers
2022-08-01 13:32 ` Ingo Molnar
2022-08-01 14:25 ` Florian Weimer
2022-08-01 14:42 ` Mathieu Desnoyers
2022-08-01 14:39 ` Mathieu Desnoyers
2022-08-01 19:40 ` Ingo Molnar
2022-07-26 19:10 ` Mathieu Desnoyers [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=790910676.83207.1658862655138.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=boqun.feng@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=posk@posk.io \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).