diff options
Diffstat (limited to 'meta/recipes-kernel/lttng/lttng-modules/0005-Fix-Remove-type-argument-from-access_ok-function-v5..patch')
-rw-r--r-- | meta/recipes-kernel/lttng/lttng-modules/0005-Fix-Remove-type-argument-from-access_ok-function-v5..patch | 204 |
1 files changed, 0 insertions, 204 deletions
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0005-Fix-Remove-type-argument-from-access_ok-function-v5..patch b/meta/recipes-kernel/lttng/lttng-modules/0005-Fix-Remove-type-argument-from-access_ok-function-v5..patch deleted file mode 100644 index 2266bbd9e0..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0005-Fix-Remove-type-argument-from-access_ok-function-v5..patch +++ /dev/null | |||
@@ -1,204 +0,0 @@ | |||
1 | From 0039dbe9891cfdf2c0d04691f83c2f342993dfd7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Jeanson <mjeanson@efficios.com> | ||
3 | Date: Wed, 9 Jan 2019 14:59:15 -0500 | ||
4 | Subject: [PATCH 5/9] Fix: Remove 'type' argument from access_ok() function | ||
5 | (v5.0) | ||
6 | |||
7 | See upstream commit : | ||
8 | |||
9 | commit 96d4f267e40f9509e8a66e2b39e8b95655617693 | ||
10 | Author: Linus Torvalds <torvalds@linux-foundation.org> | ||
11 | Date: Thu Jan 3 18:57:57 2019 -0800 | ||
12 | |||
13 | Remove 'type' argument from access_ok() function | ||
14 | |||
15 | Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument | ||
16 | of the user address range verification function since we got rid of the | ||
17 | old racy i386-only code to walk page tables by hand. | ||
18 | |||
19 | It existed because the original 80386 would not honor the write protect | ||
20 | bit when in kernel mode, so you had to do COW by hand before doing any | ||
21 | user access. But we haven't supported that in a long time, and these | ||
22 | days the 'type' argument is a purely historical artifact. | ||
23 | |||
24 | A discussion about extending 'user_access_begin()' to do the range | ||
25 | checking resulted this patch, because there is no way we're going to | ||
26 | move the old VERIFY_xyz interface to that model. And it's best done at | ||
27 | the end of the merge window when I've done most of my merges, so let's | ||
28 | just get this done once and for all. | ||
29 | |||
30 | This patch was mostly done with a sed-script, with manual fix-ups for | ||
31 | the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form. | ||
32 | |||
33 | There were a couple of notable cases: | ||
34 | |||
35 | - csky still had the old "verify_area()" name as an alias. | ||
36 | |||
37 | - the iter_iov code had magical hardcoded knowledge of the actual | ||
38 | values of VERIFY_{READ,WRITE} (not that they mattered, since nothing | ||
39 | really used it) | ||
40 | |||
41 | - microblaze used the type argument for a debug printout | ||
42 | |||
43 | but other than those oddities this should be a total no-op patch. | ||
44 | |||
45 | I tried to fix up all architectures, did fairly extensive grepping for | ||
46 | access_ok() uses, and the changes are trivial, but I may have missed | ||
47 | something. Any missed conversion should be trivially fixable, though. | ||
48 | |||
49 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | ||
50 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
51 | |||
52 | Upstream-Status: backport https://github.com/lttng/lttng-modules/commit/0039dbe9891cfdf2c0d04691f83c2f342993dfd7 | ||
53 | |||
54 | Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> | ||
55 | --- | ||
56 | lib/ringbuffer/backend.h | 8 ++++---- | ||
57 | lib/ringbuffer/ring_buffer_iterator.c | 3 ++- | ||
58 | lttng-filter-interpreter.c | 4 ++-- | ||
59 | probes/lttng-probe-user.c | 3 ++- | ||
60 | wrapper/uaccess.h | 28 +++++++++++++++++++++++++++ | ||
61 | 5 files changed, 38 insertions(+), 8 deletions(-) | ||
62 | create mode 100644 wrapper/uaccess.h | ||
63 | |||
64 | diff --git a/lib/ringbuffer/backend.h b/lib/ringbuffer/backend.h | ||
65 | index 0b75de8..3f8c108 100644 | ||
66 | --- a/lib/ringbuffer/backend.h | ||
67 | +++ b/lib/ringbuffer/backend.h | ||
68 | @@ -34,7 +34,7 @@ | ||
69 | #include <linux/list.h> | ||
70 | #include <linux/fs.h> | ||
71 | #include <linux/mm.h> | ||
72 | -#include <linux/uaccess.h> | ||
73 | +#include <wrapper/uaccess.h> | ||
74 | |||
75 | /* Internal helpers */ | ||
76 | #include <wrapper/ringbuffer/backend_internal.h> | ||
77 | @@ -302,7 +302,7 @@ void lib_ring_buffer_copy_from_user_inatomic(const struct lib_ring_buffer_config | ||
78 | |||
79 | set_fs(KERNEL_DS); | ||
80 | pagefault_disable(); | ||
81 | - if (unlikely(!access_ok(VERIFY_READ, src, len))) | ||
82 | + if (unlikely(!lttng_access_ok(VERIFY_READ, src, len))) | ||
83 | goto fill_buffer; | ||
84 | |||
85 | if (likely(pagecpy == len)) { | ||
86 | @@ -372,7 +372,7 @@ void lib_ring_buffer_strcpy_from_user_inatomic(const struct lib_ring_buffer_conf | ||
87 | |||
88 | set_fs(KERNEL_DS); | ||
89 | pagefault_disable(); | ||
90 | - if (unlikely(!access_ok(VERIFY_READ, src, len))) | ||
91 | + if (unlikely(!lttng_access_ok(VERIFY_READ, src, len))) | ||
92 | goto fill_buffer; | ||
93 | |||
94 | if (likely(pagecpy == len)) { | ||
95 | @@ -462,7 +462,7 @@ unsigned long lib_ring_buffer_copy_from_user_check_nofault(void *dest, | ||
96 | unsigned long ret; | ||
97 | mm_segment_t old_fs; | ||
98 | |||
99 | - if (!access_ok(VERIFY_READ, src, len)) | ||
100 | + if (!lttng_access_ok(VERIFY_READ, src, len)) | ||
101 | return 1; | ||
102 | old_fs = get_fs(); | ||
103 | set_fs(KERNEL_DS); | ||
104 | diff --git a/lib/ringbuffer/ring_buffer_iterator.c b/lib/ringbuffer/ring_buffer_iterator.c | ||
105 | index 61eaa5b..9645946 100644 | ||
106 | --- a/lib/ringbuffer/ring_buffer_iterator.c | ||
107 | +++ b/lib/ringbuffer/ring_buffer_iterator.c | ||
108 | @@ -27,6 +27,7 @@ | ||
109 | |||
110 | #include <wrapper/ringbuffer/iterator.h> | ||
111 | #include <wrapper/file.h> | ||
112 | +#include <wrapper/uaccess.h> | ||
113 | #include <linux/jiffies.h> | ||
114 | #include <linux/delay.h> | ||
115 | #include <linux/module.h> | ||
116 | @@ -621,7 +622,7 @@ ssize_t channel_ring_buffer_file_read(struct file *filp, | ||
117 | ssize_t len; | ||
118 | |||
119 | might_sleep(); | ||
120 | - if (!access_ok(VERIFY_WRITE, user_buf, count)) | ||
121 | + if (!lttng_access_ok(VERIFY_WRITE, user_buf, count)) | ||
122 | return -EFAULT; | ||
123 | |||
124 | /* Finish copy of previous record */ | ||
125 | diff --git a/lttng-filter-interpreter.c b/lttng-filter-interpreter.c | ||
126 | index e131462..bee2918 100644 | ||
127 | --- a/lttng-filter-interpreter.c | ||
128 | +++ b/lttng-filter-interpreter.c | ||
129 | @@ -24,7 +24,7 @@ | ||
130 | * SOFTWARE. | ||
131 | */ | ||
132 | |||
133 | -#include <linux/uaccess.h> | ||
134 | +#include <wrapper/uaccess.h> | ||
135 | #include <wrapper/frame.h> | ||
136 | #include <wrapper/types.h> | ||
137 | |||
138 | @@ -46,7 +46,7 @@ char get_char(struct estack_entry *reg, size_t offset) | ||
139 | char c; | ||
140 | |||
141 | /* Handle invalid access as end of string. */ | ||
142 | - if (unlikely(!access_ok(VERIFY_READ, | ||
143 | + if (unlikely(!lttng_access_ok(VERIFY_READ, | ||
144 | reg->u.s.user_str + offset, | ||
145 | sizeof(c)))) | ||
146 | return '\0'; | ||
147 | diff --git a/probes/lttng-probe-user.c b/probes/lttng-probe-user.c | ||
148 | index 099a66b..ed566dd 100644 | ||
149 | --- a/probes/lttng-probe-user.c | ||
150 | +++ b/probes/lttng-probe-user.c | ||
151 | @@ -20,6 +20,7 @@ | ||
152 | |||
153 | #include <linux/uaccess.h> | ||
154 | #include <linux/module.h> | ||
155 | +#include <wrapper/uaccess.h> | ||
156 | #include <probes/lttng-probe-user.h> | ||
157 | |||
158 | /* | ||
159 | @@ -43,7 +44,7 @@ long lttng_strlen_user_inatomic(const char *addr) | ||
160 | char v; | ||
161 | unsigned long ret; | ||
162 | |||
163 | - if (unlikely(!access_ok(VERIFY_READ, | ||
164 | + if (unlikely(!lttng_access_ok(VERIFY_READ, | ||
165 | (__force const char __user *) addr, | ||
166 | sizeof(v)))) | ||
167 | break; | ||
168 | diff --git a/wrapper/uaccess.h b/wrapper/uaccess.h | ||
169 | new file mode 100644 | ||
170 | index 0000000..c56427c | ||
171 | --- /dev/null | ||
172 | +++ b/wrapper/uaccess.h | ||
173 | @@ -0,0 +1,28 @@ | ||
174 | +/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) | ||
175 | + * | ||
176 | + * wrapper/uaccess.h | ||
177 | + * | ||
178 | + * wrapper around linux/uaccess.h. | ||
179 | + * | ||
180 | + * Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com> | ||
181 | + */ | ||
182 | + | ||
183 | +#ifndef _LTTNG_WRAPPER_UACCESS_H | ||
184 | +#define _LTTNG_WRAPPER_UACCESS_H | ||
185 | + | ||
186 | +#include <linux/uaccess.h> | ||
187 | +#include <lttng-kernel-version.h> | ||
188 | + | ||
189 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)) | ||
190 | + | ||
191 | +#define VERIFY_READ 0 | ||
192 | +#define VERIFY_WRITE 1 | ||
193 | +#define lttng_access_ok(type, addr, size) access_ok(addr, size) | ||
194 | + | ||
195 | +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0) */ | ||
196 | + | ||
197 | +#define lttng_access_ok(type, addr, size) access_ok(type, addr, size) | ||
198 | + | ||
199 | +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0) */ | ||
200 | + | ||
201 | +#endif /* _LTTNG_WRAPPER_UACCESS_H */ | ||
202 | -- | ||
203 | 2.19.1 | ||
204 | |||