From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4883060232394351757==" MIME-Version: 1.0 From: kbuild test robot To: kbuild-all@lists.01.org Subject: [dborkman:pr/bpf-tracing 2/2] kernel/trace/bpf_trace.c:143:40: sparse: sparse: incorrect type in argument 2 (different address spaces) Date: Mon, 21 Oct 2019 23:49:34 +0800 Message-ID: <201910212332.BeTvTNTI%lkp@intel.com> List-Id: --===============4883060232394351757== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=3Dx86_64 allmodconfig make C=3D1 CF=3D'-fdiagnostic-prefix -D__CHECK_ENDIAN__' If you fix the issue, kindly add following tag Reported-by: kbuild test robot sparse warnings: (new ones prefixed by >>) >> kernel/trace/bpf_trace.c:143:40: sparse: sparse: incorrect type in argum= ent 2 (different address spaces) @@ expected void const [noderef] *src @@ got f] *src @@ >> kernel/trace/bpf_trace.c:143:40: sparse: expected void const [noderef= ] *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 argum= ent 2 (different address spaces) @@ expected void const [noderef] *unsafe_addr @@ got f] *unsafe_addr @@ >> kernel/trace/bpf_trace.c:163:49: sparse: expected void const [noderef= ] *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 argum= ent 1 (different address spaces) @@ expected void const volatile [nodere= f] * @@ got n:1> * @@ kernel/trace/bpf_trace.c:203:14: sparse: expected void const volatile= [noderef] * kernel/trace/bpf_trace.c:203:14: sparse: got void *unsafe_ptr >> kernel/trace/bpf_trace.c:206:33: sparse: sparse: incorrect type in argum= ent 1 (different address spaces) @@ expected void [noderef] *dst= @@ got n:1> *dst @@ >> kernel/trace/bpf_trace.c:206:33: sparse: expected void [noderef] *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 =3D 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 =3D { 152 .func =3D bpf_probe_read_user, 153 .gpl_only =3D true, 154 .ret_type =3D RET_INTEGER, 155 .arg1_type =3D ARG_PTR_TO_UNINIT_MEM, 156 .arg2_type =3D ARG_CONST_SIZE_OR_ZERO, 157 .arg3_type =3D 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 =3D 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 =3D= { 172 .func =3D bpf_probe_read_str_user, 173 .gpl_only =3D true, 174 .ret_type =3D RET_INTEGER, 175 .arg1_type =3D ARG_PTR_TO_UNINIT_MEM, 176 .arg2_type =3D ARG_CONST_SIZE_OR_ZERO, 177 .arg3_type =3D ARG_ANYTHING, 178 }; 179 = 180 BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, s= rc, 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 Cent= er https://lists.01.org/pipermail/kbuild-all Intel Corporati= on --===============4883060232394351757==--