* [dborkman:pr/bpf-tracing 2/2] kernel/trace/bpf_trace.c:143:40: sparse: sparse: incorrect type in argument 2 (different address spaces)
@ 2019-10-21 15:49 kbuild test robot
0 siblings, 0 replies; only message in thread
From: kbuild test robot @ 2019-10-21 15:49 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 4667 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/dborkman/bpf.git pr/bpf-tracing
head: 7cd06ff47d15b389e9202feb7fcfe8328791659f
commit: 7cd06ff47d15b389e9202feb7fcfe8328791659f [2/2] bpf: add probe_read_{user,kernel} and probe_read_str_{user,kernel} helpers
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-dirty
git checkout 7cd06ff47d15b389e9202feb7fcfe8328791659f
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> kernel/trace/bpf_trace.c:143:40: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const [noderef] <asn:1> *src @@ got f] <asn:1> *src @@
>> kernel/trace/bpf_trace.c:143:40: sparse: expected void const [noderef] <asn:1> *src
>> kernel/trace/bpf_trace.c:143:40: sparse: got void const *unsafe_ptr
>> kernel/trace/bpf_trace.c:163:49: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const [noderef] <asn:1> *unsafe_addr @@ got f] <asn:1> *unsafe_addr @@
>> kernel/trace/bpf_trace.c:163:49: sparse: expected void const [noderef] <asn:1> *unsafe_addr
kernel/trace/bpf_trace.c:163:49: sparse: got void const *unsafe_ptr
kernel/trace/bpf_trace.c:203:14: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] <asn:1> * @@ got n:1> * @@
kernel/trace/bpf_trace.c:203:14: sparse: expected void const volatile [noderef] <asn:1> *
kernel/trace/bpf_trace.c:203:14: sparse: got void *unsafe_ptr
>> kernel/trace/bpf_trace.c:206:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] <asn:1> *dst @@ got n:1> *dst @@
>> kernel/trace/bpf_trace.c:206:33: sparse: expected void [noderef] <asn:1> *dst
kernel/trace/bpf_trace.c:206:33: sparse: got void *unsafe_ptr
vim +143 kernel/trace/bpf_trace.c
140
141 BPF_CALL_3(bpf_probe_read_user, void *, dst, u32, size, const void *, unsafe_ptr)
142 {
> 143 int ret = probe_user_read(dst, unsafe_ptr, size);
144
145 if (unlikely(ret < 0))
146 memset(dst, 0, size);
147
148 return ret;
149 }
150
151 static const struct bpf_func_proto bpf_probe_read_user_proto = {
152 .func = bpf_probe_read_user,
153 .gpl_only = true,
154 .ret_type = RET_INTEGER,
155 .arg1_type = ARG_PTR_TO_UNINIT_MEM,
156 .arg2_type = ARG_CONST_SIZE_OR_ZERO,
157 .arg3_type = ARG_ANYTHING,
158 };
159
160 BPF_CALL_3(bpf_probe_read_str_user, void *, dst, u32, size,
161 const void *, unsafe_ptr)
162 {
> 163 int ret = strncpy_from_unsafe_user(dst, unsafe_ptr, size);
164
165 if (unlikely(ret < 0))
166 memset(dst, 0, size);
167
168 return ret;
169 }
170
171 static const struct bpf_func_proto bpf_probe_read_str_user_proto = {
172 .func = bpf_probe_read_str_user,
173 .gpl_only = true,
174 .ret_type = RET_INTEGER,
175 .arg1_type = ARG_PTR_TO_UNINIT_MEM,
176 .arg2_type = ARG_CONST_SIZE_OR_ZERO,
177 .arg3_type = ARG_ANYTHING,
178 };
179
180 BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src,
181 u32, size)
182 {
183 /*
184 * Ensure we're in user context which is safe for the helper to
185 * run. This helper has no business in a kthread.
186 *
187 * access_ok() should prevent writing to non-user memory, but in
188 * some situations (nommu, temporary switch, etc) access_ok() does
189 * not provide enough validation, hence the check on KERNEL_DS.
190 *
191 * nmi_uaccess_okay() ensures the probe is not run in an interim
192 * state, when the task or mm are switched. This is specifically
193 * required to prevent the use of temporary mm.
194 */
195
196 if (unlikely(in_interrupt() ||
197 current->flags & (PF_KTHREAD | PF_EXITING)))
198 return -EPERM;
199 if (unlikely(uaccess_kernel()))
200 return -EPERM;
201 if (unlikely(!nmi_uaccess_okay()))
202 return -EPERM;
203 if (!access_ok(unsafe_ptr, size))
204 return -EPERM;
205
> 206 return probe_user_write(unsafe_ptr, src, size);
207 }
208
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-10-21 15:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21 15:49 [dborkman:pr/bpf-tracing 2/2] kernel/trace/bpf_trace.c:143:40: sparse: sparse: incorrect type in argument 2 (different address spaces) kbuild test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.