----- On Jul 6, 2018, at 12:02 PM, Mathieu Desnoyers 
[email protected] wrote:

> ----- On Jul 5, 2018, at 2:05 PM, Mathieu Desnoyers
> [email protected] wrote:
> 
[...]
> The 0-day bot noticed that __get_user() is unimplemented for 64-bit
> values on arm32 (although get_user() is implemented).
> 
> The following diff fixes this discrepancy, and allows this rseq patch
> to build on arm32:
> 

For -rc, I would favor the following simpler approach. Or I could even
just use get_user() instead. Thoughts ?

    rseq: implement work-around for missing 8-byte __get_user on arm
    
    Now that rseq uses __u64 for its pointer fields, 32-bit architectures
    need to read this 64-bit value from user-space.
    
    __get_user is used to read this value, given that its access check has
    already been performed with access_ok() on rseq registration.
    
    arm does not implement 8-byte __get_user. Work-around this limitation
    by using get_user() on ARM instead, with its redundant access check.
    
    Signed-off-by: Mathieu Desnoyers <[email protected]>
    CC: Thomas Gleixner <[email protected]>
    Cc: Joel Fernandes <[email protected]>
    Cc: Peter Zijlstra <[email protected]>
    Cc: Catalin Marinas <[email protected]>
    Cc: Dave Watson <[email protected]>
    Cc: Will Deacon <[email protected]>
    Cc: Andi Kleen <[email protected]>
    Cc: "H . Peter Anvin" <[email protected]>
    Cc: Chris Lameter <[email protected]>
    Cc: Russell King <[email protected]>
    Cc: Andrew Hunter <[email protected]>
    Cc: Michael Kerrisk <[email protected]>
    Cc: "Paul E . McKenney" <[email protected]>
    Cc: Paul Turner <[email protected]>
    Cc: Boqun Feng <[email protected]>
    Cc: Josh Triplett <[email protected]>
    Cc: Steven Rostedt <[email protected]>
    Cc: Ben Maurer <[email protected]>
    Cc: [email protected]
    CC: [email protected]
    Cc: Andy Lutomirski <[email protected]>
    Cc: Andrew Morton <[email protected]>
    Cc: Linus Torvalds <[email protected]>

diff --git a/kernel/rseq.c b/kernel/rseq.c
index 3081e67..0e67625 100644
--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -18,6 +18,16 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/rseq.h>
 
+/*
+ * ARM does not implement 8 bytes __get_user. Use get_user on that
+ * architecture instead.
+ */
+#ifdef CONFIG_ARM
+#define __rseq_get_user                get_user
+#else
+#define __rseq_get_user                __get_user
+#endif
+
 #define RSEQ_CS_PREEMPT_MIGRATE_FLAGS (RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE | \
                                       RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT)
 
@@ -120,7 +130,7 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rs
        u32 sig;
        int ret;
 
-       ret = __get_user(ptr, &t->rseq->rseq_cs.ptr64);
+       ret = __rseq_get_user(ptr, &t->rseq->rseq_cs.ptr64);
        if (ret)
                return ret;
        if (!ptr) {



-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

Reply via email to