History

copy_to_user, copy_from_user: Use generic instrumented.h

This replaces the KASAN instrumentation with generic instrumentation, implicitly adding KCSAN instrumentation support. For KASAN no functional change is intended.

Marco Elver committed 6 years ago

Commit 76d6f061 parent d0ef4c32 files · +11 −10Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/uaccess.h+7−7
@@ -2,9 +2,9 @@ · 1 unmodified line
22 #ifndef __LINUX_UACCESS_H__
33 #define __LINUX_UACCESS_H__
44
5+#include <linux/instrumented.h>
56 #include <linux/sched.h>
67 #include <linux/thread_info.h>
7−#include <linux/kasan-checks.h>
88
99 #define uaccess_kernel() segment_eq(get_fs(), KERNEL_DS)
1010
@@ -58,7 +58,7 @@ · 47 unmodified lines
5858 static __always_inline __must_check unsigned long
5959 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
6060 {
61− kasan_check_write(to, n);
61+ instrument_copy_from_user(to, from, n);
6262 check_object_size(to, n, false);
6363 return raw_copy_from_user(to, from, n);
6464 }
@@ -67,7 +67,7 @@ static __always_inline __must_check unsigned long · 2 unmodified lines
6767 __copy_from_user(void *to, const void __user *from, unsigned long n)
6868 {
6969 might_fault();
70− kasan_check_write(to, n);
70+ instrument_copy_from_user(to, from, n);
7171 check_object_size(to, n, false);
7272 return raw_copy_from_user(to, from, n);
7373 }
@@ -88,7 +88,7 @@ __copy_from_user(void *to, const void __user *from, unsigned long n) · 14 unmodified lines
8888 static __always_inline __must_check unsigned long
8989 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
9090 {
91− kasan_check_read(from, n);
91+ instrument_copy_to_user(to, from, n);
9292 check_object_size(from, n, true);
9393 return raw_copy_to_user(to, from, n);
9494 }
@@ -97,7 +97,7 @@ static __always_inline __must_check unsigned long · 2 unmodified lines
9797 __copy_to_user(void __user *to, const void *from, unsigned long n)
9898 {
9999 might_fault();
100− kasan_check_read(from, n);
100+ instrument_copy_to_user(to, from, n);
101101 check_object_size(from, n, true);
102102 return raw_copy_to_user(to, from, n);
103103 }
@@ -109,7 +109,7 @@ _copy_from_user(void *to, const void __user *from, unsigned long n) · 5 unmodified lines
109109 unsigned long res = n;
110110 might_fault();
111111 if (likely(access_ok(from, n))) {
112− kasan_check_write(to, n);
112+ instrument_copy_from_user(to, from, n);
113113 res = raw_copy_from_user(to, from, n);
114114 }
115115 if (unlikely(res))
@@ -127,7 +127,7 @@ _copy_to_user(void __user *to, const void *from, unsigned long n) · 11 unmodified lines
127127 {
128128 might_fault();
129129 if (access_ok(to, n)) {
130− kasan_check_read(from, n);
130+ instrument_copy_to_user(to, from, n);
131131 n = raw_copy_to_user(to, from, n);
132132 }
133133 return n;