Commit ba0f4722 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 8cac8990 463f550f
...@@ -1929,11 +1929,11 @@ static inline void rseq_migrate(struct task_struct *t) ...@@ -1929,11 +1929,11 @@ static inline void rseq_migrate(struct task_struct *t)
/* /*
* If parent process has a registered restartable sequences area, the * If parent process has a registered restartable sequences area, the
* child inherits. Only applies when forking a process, not a thread. * child inherits. Unregister rseq for a clone with CLONE_VM set.
*/ */
static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags) static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags)
{ {
if (clone_flags & CLONE_THREAD) { if (clone_flags & CLONE_VM) {
t->rseq = NULL; t->rseq = NULL;
t->rseq_sig = 0; t->rseq_sig = 0;
t->rseq_event_mask = 0; t->rseq_event_mask = 0;
......
...@@ -310,6 +310,8 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, ...@@ -310,6 +310,8 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
int ret; int ret;
if (flags & RSEQ_FLAG_UNREGISTER) { if (flags & RSEQ_FLAG_UNREGISTER) {
if (flags & ~RSEQ_FLAG_UNREGISTER)
return -EINVAL;
/* Unregister rseq for current thread. */ /* Unregister rseq for current thread. */
if (current->rseq != rseq || !current->rseq) if (current->rseq != rseq || !current->rseq)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment