maple_tree: fix freeing of nodes in rcu mode
[platform/kernel/linux-starfive.git] / lib / usercopy.c
index 1505a52..d29fe29 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/fault-inject-usercopy.h>
 #include <linux/instrumented.h>
 #include <linux/uaccess.h>
+#include <linux/nospec.h>
 
 /* out-of-line parts */
 
@@ -12,6 +13,12 @@ unsigned long _copy_from_user(void *to, const void __user *from, unsigned long n
        unsigned long res = n;
        might_fault();
        if (!should_fail_usercopy() && likely(access_ok(from, n))) {
+               /*
+                * Ensure that bad access_ok() speculation will not
+                * lead to nasty side effects *after* the copy is
+                * finished:
+                */
+               barrier_nospec();
                instrument_copy_from_user_before(to, from, n);
                res = raw_copy_from_user(to, from, n);
                instrument_copy_from_user_after(to, from, n, res);