hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/lib/usercopy.c
....@@ -3,6 +3,7 @@
33 #include <linux/fault-inject-usercopy.h>
44 #include <linux/instrumented.h>
55 #include <linux/uaccess.h>
6
+#include <linux/nospec.h>
67
78 /* out-of-line parts */
89
....@@ -12,6 +13,12 @@
1213 unsigned long res = n;
1314 might_fault();
1415 if (!should_fail_usercopy() && likely(access_ok(from, n))) {
16
+ /*
17
+ * Ensure that bad access_ok() speculation will not
18
+ * lead to nasty side effects *after* the copy is
19
+ * finished:
20
+ */
21
+ barrier_nospec();
1522 instrument_copy_from_user(to, from, n);
1623 res = raw_copy_from_user(to, from, n);
1724 }