Skip to content

Commit 8f28177

Browse files
compudjKAGA-KOKO
authored andcommitted
rseq: Use get_user/put_user rather than __get_user/__put_user
__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]
1 parent e96d713 commit 8f28177

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

kernel/rseq.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ static int rseq_update_cpu_id(struct task_struct *t)
8585
{
8686
u32 cpu_id = raw_smp_processor_id();
8787

88-
if (__put_user(cpu_id, &t->rseq->cpu_id_start))
88+
if (put_user(cpu_id, &t->rseq->cpu_id_start))
8989
return -EFAULT;
90-
if (__put_user(cpu_id, &t->rseq->cpu_id))
90+
if (put_user(cpu_id, &t->rseq->cpu_id))
9191
return -EFAULT;
9292
trace_rseq_update(t);
9393
return 0;
@@ -100,14 +100,14 @@ static int rseq_reset_rseq_cpu_id(struct task_struct *t)
100100
/*
101101
* Reset cpu_id_start to its initial state (0).
102102
*/
103-
if (__put_user(cpu_id_start, &t->rseq->cpu_id_start))
103+
if (put_user(cpu_id_start, &t->rseq->cpu_id_start))
104104
return -EFAULT;
105105
/*
106106
* Reset cpu_id to RSEQ_CPU_ID_UNINITIALIZED, so any user coming
107107
* in after unregistration can figure out that rseq needs to be
108108
* registered again.
109109
*/
110-
if (__put_user(cpu_id, &t->rseq->cpu_id))
110+
if (put_user(cpu_id, &t->rseq->cpu_id))
111111
return -EFAULT;
112112
return 0;
113113
}
@@ -120,7 +120,7 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs)
120120
u32 sig;
121121
int ret;
122122

123-
ret = __get_user(ptr, &t->rseq->rseq_cs);
123+
ret = get_user(ptr, &t->rseq->rseq_cs);
124124
if (ret)
125125
return ret;
126126
if (!ptr) {
@@ -163,7 +163,7 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags)
163163
int ret;
164164

165165
/* Get thread flags. */
166-
ret = __get_user(flags, &t->rseq->flags);
166+
ret = get_user(flags, &t->rseq->flags);
167167
if (ret)
168168
return ret;
169169

@@ -203,7 +203,7 @@ static int clear_rseq_cs(struct task_struct *t)
203203
*
204204
* Set rseq_cs to NULL with single-copy atomicity.
205205
*/
206-
return __put_user(0UL, &t->rseq->rseq_cs);
206+
return put_user(0UL, &t->rseq->rseq_cs);
207207
}
208208

209209
/*

0 commit comments

Comments
 (0)