Skip to content

Commit ba0f472

Browse files
committed
Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull rseq fixes from Ingo Molnar: "Two rseq bugfixes: - CLONE_VM !CLONE_THREAD didn't work properly, the kernel would end up corrupting the TLS of the parent. Technically a change in the ABI but the previous behavior couldn't resonably have been relied on by applications so this looks like a valid exception to the ABI rule. - Make the RSEQ_FLAG_UNREGISTER ABI behavior consistent with the handling of other flags. This is not thought to impact any applications either" * 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: rseq: Unregister rseq for clone CLONE_VM rseq: Reject unknown flags on rseq unregister
2 parents 8cac899 + 463f550 commit ba0f472

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

include/linux/sched.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,11 +1929,11 @@ static inline void rseq_migrate(struct task_struct *t)
19291929

19301930
/*
19311931
* If parent process has a registered restartable sequences area, the
1932-
* child inherits. Only applies when forking a process, not a thread.
1932+
* child inherits. Unregister rseq for a clone with CLONE_VM set.
19331933
*/
19341934
static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags)
19351935
{
1936-
if (clone_flags & CLONE_THREAD) {
1936+
if (clone_flags & CLONE_VM) {
19371937
t->rseq = NULL;
19381938
t->rseq_sig = 0;
19391939
t->rseq_event_mask = 0;

kernel/rseq.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
310310
int ret;
311311

312312
if (flags & RSEQ_FLAG_UNREGISTER) {
313+
if (flags & ~RSEQ_FLAG_UNREGISTER)
314+
return -EINVAL;
313315
/* Unregister rseq for current thread. */
314316
if (current->rseq != rseq || !current->rseq)
315317
return -EINVAL;

0 commit comments

Comments
 (0)