Skip to content

Commit

Permalink
rseq: Use get_user/put_user rather than __get_user/__put_user
Browse files Browse the repository at this point in the history
__get_user()/__put_user() is used to read values for address ranges that
were already checked with access_ok() on rseq registration.

It has been recognized that __get_user/__put_user are optimizing the
wrong thing. Replace them by get_user/put_user across rseq instead.

If those end up showing up in benchmarks, the proper approach would be to
use user_access_begin() / unsafe_{get,put}_user() / user_access_end()
anyway.

Signed-off-by: Mathieu Desnoyers <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Cc: Peter Zijlstra <[email protected]>
Cc: "Paul E . McKenney" <[email protected]>
Cc: Boqun Feng <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Dave Watson <[email protected]>
Cc: Paul Turner <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Russell King <[email protected]>
Cc: "H . Peter Anvin" <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Chris Lameter <[email protected]>
Cc: Ben Maurer <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Josh Triplett <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Michael Kerrisk <[email protected]>
Cc: Joel Fernandes <[email protected]>
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
compudj authored and KAGA-KOKO committed Jul 10, 2018
1 parent e96d713 commit 8f28177
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions kernel/rseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ static int rseq_update_cpu_id(struct task_struct *t)
{
u32 cpu_id = raw_smp_processor_id();

if (__put_user(cpu_id, &t->rseq->cpu_id_start))
if (put_user(cpu_id, &t->rseq->cpu_id_start))
return -EFAULT;
if (__put_user(cpu_id, &t->rseq->cpu_id))
if (put_user(cpu_id, &t->rseq->cpu_id))
return -EFAULT;
trace_rseq_update(t);
return 0;
Expand All @@ -100,14 +100,14 @@ static int rseq_reset_rseq_cpu_id(struct task_struct *t)
/*
* Reset cpu_id_start to its initial state (0).
*/
if (__put_user(cpu_id_start, &t->rseq->cpu_id_start))
if (put_user(cpu_id_start, &t->rseq->cpu_id_start))
return -EFAULT;
/*
* Reset cpu_id to RSEQ_CPU_ID_UNINITIALIZED, so any user coming
* in after unregistration can figure out that rseq needs to be
* registered again.
*/
if (__put_user(cpu_id, &t->rseq->cpu_id))
if (put_user(cpu_id, &t->rseq->cpu_id))
return -EFAULT;
return 0;
}
Expand All @@ -120,7 +120,7 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs)
u32 sig;
int ret;

ret = __get_user(ptr, &t->rseq->rseq_cs);
ret = get_user(ptr, &t->rseq->rseq_cs);
if (ret)
return ret;
if (!ptr) {
Expand Down Expand Up @@ -163,7 +163,7 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags)
int ret;

/* Get thread flags. */
ret = __get_user(flags, &t->rseq->flags);
ret = get_user(flags, &t->rseq->flags);
if (ret)
return ret;

Expand Down Expand Up @@ -203,7 +203,7 @@ static int clear_rseq_cs(struct task_struct *t)
*
* Set rseq_cs to NULL with single-copy atomicity.
*/
return __put_user(0UL, &t->rseq->rseq_cs);
return put_user(0UL, &t->rseq->rseq_cs);
}

/*
Expand Down

0 comments on commit 8f28177

Please sign in to comment.