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
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
58static __always_inline __must_check unsigned long58static __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
88static __always_inline __must_check unsigned long88static __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;