This replaces the KASAN instrumentation with generic instrumentation, implicitly adding KCSAN instrumentation support. For KASAN no functional change is intended.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -2,9 +2,9 @@ · 1 unmodified line | |||
| 2 | #ifndef __LINUX_UACCESS_H__ | 2 | #ifndef __LINUX_UACCESS_H__ |
| 3 | #define __LINUX_UACCESS_H__ | 3 | #define __LINUX_UACCESS_H__ |
| 4 | 4 | ||
| 5 | #include <linux/instrumented.h> | ||
| 5 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
| 6 | #include <linux/thread_info.h> | 7 | #include <linux/thread_info.h> |
| 7 | #include <linux/kasan-checks.h> | ||
| 8 | 8 | ||
| 9 | #define uaccess_kernel() segment_eq(get_fs(), KERNEL_DS) | 9 | #define uaccess_kernel() segment_eq(get_fs(), KERNEL_DS) |
| 10 | 10 | ||
| @@ -58,7 +58,7 @@ · 47 unmodified lines | |||
| 58 | static __always_inline __must_check unsigned long | 58 | static __always_inline __must_check unsigned long |
| 59 | __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n) | 59 | __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n) |
| 60 | { | 60 | { |
| 61 | kasan_check_write(to, n); | 61 | instrument_copy_from_user(to, from, n); |
| 62 | check_object_size(to, n, false); | 62 | check_object_size(to, n, false); |
| 63 | return raw_copy_from_user(to, from, n); | 63 | return raw_copy_from_user(to, from, n); |
| 64 | } | 64 | } |
| @@ -67,7 +67,7 @@ static __always_inline __must_check unsigned long · 2 unmodified lines | |||
| 67 | __copy_from_user(void *to, const void __user *from, unsigned long n) | 67 | __copy_from_user(void *to, const void __user *from, unsigned long n) |
| 68 | { | 68 | { |
| 69 | might_fault(); | 69 | might_fault(); |
| 70 | kasan_check_write(to, n); | 70 | instrument_copy_from_user(to, from, n); |
| 71 | check_object_size(to, n, false); | 71 | check_object_size(to, n, false); |
| 72 | return raw_copy_from_user(to, from, n); | 72 | return raw_copy_from_user(to, from, n); |
| 73 | } | 73 | } |
| @@ -88,7 +88,7 @@ __copy_from_user(void *to, const void __user *from, unsigned long n) · 14 unmodified lines | |||
| 88 | static __always_inline __must_check unsigned long | 88 | static __always_inline __must_check unsigned long |
| 89 | __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n) | 89 | __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n) |
| 90 | { | 90 | { |
| 91 | kasan_check_read(from, n); | 91 | instrument_copy_to_user(to, from, n); |
| 92 | check_object_size(from, n, true); | 92 | check_object_size(from, n, true); |
| 93 | return raw_copy_to_user(to, from, n); | 93 | return raw_copy_to_user(to, from, n); |
| 94 | } | 94 | } |
| @@ -97,7 +97,7 @@ static __always_inline __must_check unsigned long · 2 unmodified lines | |||
| 97 | __copy_to_user(void __user *to, const void *from, unsigned long n) | 97 | __copy_to_user(void __user *to, const void *from, unsigned long n) |
| 98 | { | 98 | { |
| 99 | might_fault(); | 99 | might_fault(); |
| 100 | kasan_check_read(from, n); | 100 | instrument_copy_to_user(to, from, n); |
| 101 | check_object_size(from, n, true); | 101 | check_object_size(from, n, true); |
| 102 | return raw_copy_to_user(to, from, n); | 102 | return raw_copy_to_user(to, from, n); |
| 103 | } | 103 | } |
| @@ -109,7 +109,7 @@ _copy_from_user(void *to, const void __user *from, unsigned long n) · 5 unmodified lines | |||
| 109 | unsigned long res = n; | 109 | unsigned long res = n; |
| 110 | might_fault(); | 110 | might_fault(); |
| 111 | if (likely(access_ok(from, n))) { | 111 | if (likely(access_ok(from, n))) { |
| 112 | kasan_check_write(to, n); | 112 | instrument_copy_from_user(to, from, n); |
| 113 | res = raw_copy_from_user(to, from, n); | 113 | res = raw_copy_from_user(to, from, n); |
| 114 | } | 114 | } |
| 115 | if (unlikely(res)) | 115 | if (unlikely(res)) |
| @@ -127,7 +127,7 @@ _copy_to_user(void __user *to, const void *from, unsigned long n) · 11 unmodified lines | |||
| 127 | { | 127 | { |
| 128 | might_fault(); | 128 | might_fault(); |
| 129 | if (access_ok(to, n)) { | 129 | if (access_ok(to, n)) { |
| 130 | kasan_check_read(from, n); | 130 | instrument_copy_to_user(to, from, n); |
| 131 | n = raw_copy_to_user(to, from, n); | 131 | n = raw_copy_to_user(to, from, n); |
| 132 | } | 132 | } |
| 133 | return n; | 133 | return n; |