提交 83b0b15b 编写于 作者: M Mathieu Desnoyers 提交者: Ingo Molnar

rseq: Remove superfluous rseq_len from task_struct

The rseq system call, when invoked with flags of "0" or
"RSEQ_FLAG_UNREGISTER" values, expects the rseq_len parameter to
be equal to sizeof(struct rseq), which is fixed-size and fixed-layout,
specified in uapi linux/rseq.h.

Expecting a fixed size for rseq_len is a design choice that ensures
multiple libraries and application defining __rseq_abi in the same
process agree on its exact size.

Considering that this size is and will always be the same value, there
is no point in saving this value within task_struct rseq_len. Remove
this field from task_struct.

No change in functionality intended.
Signed-off-by: NMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Ben Maurer <bmaurer@fb.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Lameter <cl@linux.com>
Cc: Dave Watson <davejwatson@fb.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul Turner <pjt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-api@vger.kernel.org
Link: http://lkml.kernel.org/r/20190305194755.2602-3-mathieu.desnoyers@efficios.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 bff9504b
...@@ -1057,7 +1057,6 @@ struct task_struct { ...@@ -1057,7 +1057,6 @@ struct task_struct {
#ifdef CONFIG_RSEQ #ifdef CONFIG_RSEQ
struct rseq __user *rseq; struct rseq __user *rseq;
u32 rseq_len;
u32 rseq_sig; u32 rseq_sig;
/* /*
* RmW on rseq_event_mask must be performed atomically * RmW on rseq_event_mask must be performed atomically
...@@ -1855,12 +1854,10 @@ static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags) ...@@ -1855,12 +1854,10 @@ static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags)
{ {
if (clone_flags & CLONE_THREAD) { if (clone_flags & CLONE_THREAD) {
t->rseq = NULL; t->rseq = NULL;
t->rseq_len = 0;
t->rseq_sig = 0; t->rseq_sig = 0;
t->rseq_event_mask = 0; t->rseq_event_mask = 0;
} else { } else {
t->rseq = current->rseq; t->rseq = current->rseq;
t->rseq_len = current->rseq_len;
t->rseq_sig = current->rseq_sig; t->rseq_sig = current->rseq_sig;
t->rseq_event_mask = current->rseq_event_mask; t->rseq_event_mask = current->rseq_event_mask;
} }
...@@ -1869,7 +1866,6 @@ static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags) ...@@ -1869,7 +1866,6 @@ static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags)
static inline void rseq_execve(struct task_struct *t) static inline void rseq_execve(struct task_struct *t)
{ {
t->rseq = NULL; t->rseq = NULL;
t->rseq_len = 0;
t->rseq_sig = 0; t->rseq_sig = 0;
t->rseq_event_mask = 0; t->rseq_event_mask = 0;
} }
......
...@@ -313,7 +313,7 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, ...@@ -313,7 +313,7 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
/* 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;
if (current->rseq_len != rseq_len) if (rseq_len != sizeof(*rseq))
return -EINVAL; return -EINVAL;
if (current->rseq_sig != sig) if (current->rseq_sig != sig)
return -EPERM; return -EPERM;
...@@ -321,7 +321,6 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, ...@@ -321,7 +321,6 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
if (ret) if (ret)
return ret; return ret;
current->rseq = NULL; current->rseq = NULL;
current->rseq_len = 0;
current->rseq_sig = 0; current->rseq_sig = 0;
return 0; return 0;
} }
...@@ -335,7 +334,7 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, ...@@ -335,7 +334,7 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
* the provided address differs from the prior * the provided address differs from the prior
* one. * one.
*/ */
if (current->rseq != rseq || current->rseq_len != rseq_len) if (current->rseq != rseq || rseq_len != sizeof(*rseq))
return -EINVAL; return -EINVAL;
if (current->rseq_sig != sig) if (current->rseq_sig != sig)
return -EPERM; return -EPERM;
...@@ -353,7 +352,6 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, ...@@ -353,7 +352,6 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
if (!access_ok(rseq, rseq_len)) if (!access_ok(rseq, rseq_len))
return -EFAULT; return -EFAULT;
current->rseq = rseq; current->rseq = rseq;
current->rseq_len = rseq_len;
current->rseq_sig = sig; current->rseq_sig = sig;
/* /*
* If rseq was previously inactive, and has just been * If rseq was previously inactive, and has just been
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册