Skip to content

Commit 0190e41

Browse files
compudjIngo Molnar
authored andcommitted
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/[email protected]/ [1] Link: https://lore.kernel.org/lkml/[email protected]/ [2] Link: https://lore.kernel.org/lkml/[email protected]/ [3] Signed-off-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]
1 parent 91caa5a commit 0190e41

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

kernel/rseq.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
#define CREATE_TRACE_POINTS
1919
#include <trace/events/rseq.h>
2020

21-
#define RSEQ_CS_PREEMPT_MIGRATE_FLAGS (RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE | \
22-
RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT)
21+
#define RSEQ_CS_NO_RESTART_FLAGS (RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT | \
22+
RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL | \
23+
RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE)
2324

2425
/*
2526
*
@@ -175,23 +176,15 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags)
175176
u32 flags, event_mask;
176177
int ret;
177178

179+
if (WARN_ON_ONCE(cs_flags & RSEQ_CS_NO_RESTART_FLAGS))
180+
return -EINVAL;
181+
178182
/* Get thread flags. */
179183
ret = get_user(flags, &t->rseq->flags);
180184
if (ret)
181185
return ret;
182186

183-
/* Take critical section flags into account. */
184-
flags |= cs_flags;
185-
186-
/*
187-
* Restart on signal can only be inhibited when restart on
188-
* preempt and restart on migrate are inhibited too. Otherwise,
189-
* a preempted signal handler could fail to restart the prior
190-
* execution context on sigreturn.
191-
*/
192-
if (unlikely((flags & RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL) &&
193-
(flags & RSEQ_CS_PREEMPT_MIGRATE_FLAGS) !=
194-
RSEQ_CS_PREEMPT_MIGRATE_FLAGS))
187+
if (WARN_ON_ONCE(flags & RSEQ_CS_NO_RESTART_FLAGS))
195188
return -EINVAL;
196189

197190
/*
@@ -203,7 +196,7 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags)
203196
t->rseq_event_mask = 0;
204197
preempt_enable();
205198

206-
return !!(event_mask & ~flags);
199+
return !!event_mask;
207200
}
208201

209202
static int clear_rseq_cs(struct task_struct *t)

0 commit comments

Comments
 (0)