[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202005192056.JWpR8L0N%lkp@intel.com>
Date: Tue, 19 May 2020 20:58:15 +0800
From: kbuild test robot <lkp@...el.com>
To: Daniel Borkmann <daniel@...earbox.net>
Cc: kbuild-all@...ts.01.org, clang-built-linux@...glegroups.com,
linux-kernel@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
Masami Hiramatsu <mhiramat@...nel.org>
Subject: kernel/trace/bpf_trace.c:216:36: warning: unused variable
'bpf_probe_read_compat_proto'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 642b151f45dd54809ea00ecd3976a56c1ec9b53d
commit: 0ebeea8ca8a4d1d453ad299aef0507dab04f6e8d bpf: Restrict bpf_probe_read{, str}() only to archs where they work
date: 4 days ago
config: s390-randconfig-r021-20200519 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 135b877874fae96b4372c8a3fbfaa8ff44ff86e3)
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390-linux-gnu
git checkout 0ebeea8ca8a4d1d453ad299aef0507dab04f6e8d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@...el.com>
All warnings (new ones prefixed by >>, old ones prefixed by <<):
In file included from include/linux/skbuff.h:31:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:492:45: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
___constant_swab32(x) : ^
include/uapi/linux/swab.h:20:12: note: expanded from macro '___constant_swab32'
(((__u32)(x) & (__u32)0x0000ff00UL) << 8) | ^
In file included from kernel/trace/bpf_trace.c:10:
In file included from include/linux/filter.h:13:
In file included from include/linux/skbuff.h:31:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:492:45: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
___constant_swab32(x) : ^
include/uapi/linux/swab.h:21:12: note: expanded from macro '___constant_swab32'
(((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | ^
In file included from kernel/trace/bpf_trace.c:10:
In file included from include/linux/filter.h:13:
In file included from include/linux/skbuff.h:31:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:492:45: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
___constant_swab32(x) : ^
include/uapi/linux/swab.h:22:12: note: expanded from macro '___constant_swab32'
(((__u32)(x) & (__u32)0xff000000UL) >> 24)))
^
In file included from kernel/trace/bpf_trace.c:10:
In file included from include/linux/filter.h:13:
In file included from include/linux/skbuff.h:31:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:492:45: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:120:12: note: expanded from macro '__swab32'
__fswab32(x))
^
In file included from kernel/trace/bpf_trace.c:10:
In file included from include/linux/filter.h:13:
In file included from include/linux/skbuff.h:31:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:503:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:513:46: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew(cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:523:46: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel(cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:585:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:593:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:601:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:610:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:619:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:628:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
>> kernel/trace/bpf_trace.c:216:36: warning: unused variable 'bpf_probe_read_compat_proto' [-Wunused-const-variable]
static const struct bpf_func_proto bpf_probe_read_compat_proto = {
^
>> kernel/trace/bpf_trace.c:271:36: warning: unused variable 'bpf_probe_read_compat_str_proto' [-Wunused-const-variable]
static const struct bpf_func_proto bpf_probe_read_compat_str_proto = {
^
22 warnings generated.
vim +/bpf_probe_read_compat_proto +216 kernel/trace/bpf_trace.c
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 215
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 @216 static const struct bpf_func_proto bpf_probe_read_compat_proto = {
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 217 .func = bpf_probe_read_compat,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 218 .gpl_only = true,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 219 .ret_type = RET_INTEGER,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 220 .arg1_type = ARG_PTR_TO_UNINIT_MEM,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 221 .arg2_type = ARG_CONST_SIZE_OR_ZERO,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 222 .arg3_type = ARG_ANYTHING,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 223 };
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 224
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 225 static __always_inline int
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 226 bpf_probe_read_kernel_str_common(void *dst, u32 size, const void *unsafe_ptr,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 227 const bool compat)
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 228 {
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 229 int ret = security_locked_down(LOCKDOWN_BPF_READ);
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 230
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 231 if (unlikely(ret < 0))
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 232 goto out;
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 233 /*
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 234 * The strncpy_from_unsafe_*() call will likely not fill the entire
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 235 * buffer, but that's okay in this circumstance as we're probing
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 236 * arbitrary memory anyway similar to bpf_probe_read_*() and might
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 237 * as well probe the stack. Thus, memory is explicitly cleared
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 238 * only in error case, so that improper users ignoring return
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 239 * code altogether don't copy garbage; otherwise length of string
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 240 * is returned that can be used for bpf_perf_event_output() et al.
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 241 */
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 242 ret = compat ? strncpy_from_unsafe(dst, unsafe_ptr, size) :
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 243 strncpy_from_unsafe_strict(dst, unsafe_ptr, size);
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 244 if (unlikely(ret < 0))
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 245 out:
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 246 memset(dst, 0, size);
074f528eed408b4 Daniel Borkmann 2016-04-13 247 return ret;
2541517c32be253 Alexei Starovoitov 2015-03-25 248 }
2541517c32be253 Alexei Starovoitov 2015-03-25 249
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 250 BPF_CALL_3(bpf_probe_read_kernel_str, void *, dst, u32, size,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 251 const void *, unsafe_ptr)
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 252 {
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 253 return bpf_probe_read_kernel_str_common(dst, size, unsafe_ptr, false);
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 254 }
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 255
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 256 static const struct bpf_func_proto bpf_probe_read_kernel_str_proto = {
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 257 .func = bpf_probe_read_kernel_str,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 258 .gpl_only = true,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 259 .ret_type = RET_INTEGER,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 260 .arg1_type = ARG_PTR_TO_UNINIT_MEM,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 261 .arg2_type = ARG_CONST_SIZE_OR_ZERO,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 262 .arg3_type = ARG_ANYTHING,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 263 };
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 264
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 265 BPF_CALL_3(bpf_probe_read_compat_str, void *, dst, u32, size,
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 266 const void *, unsafe_ptr)
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 267 {
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 268 return bpf_probe_read_kernel_str_common(dst, size, unsafe_ptr, true);
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 269 }
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 270
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 @271 static const struct bpf_func_proto bpf_probe_read_compat_str_proto = {
6ae08ae3dea2cfa Daniel Borkmann 2019-11-02 272 .func = bpf_probe_read_compat_str,
2541517c32be253 Alexei Starovoitov 2015-03-25 273 .gpl_only = true,
2541517c32be253 Alexei Starovoitov 2015-03-25 274 .ret_type = RET_INTEGER,
39f19ebbf57b403 Alexei Starovoitov 2017-01-09 275 .arg1_type = ARG_PTR_TO_UNINIT_MEM,
9c019e2bc4b2bd8 Yonghong Song 2017-11-12 276 .arg2_type = ARG_CONST_SIZE_OR_ZERO,
2541517c32be253 Alexei Starovoitov 2015-03-25 277 .arg3_type = ARG_ANYTHING,
2541517c32be253 Alexei Starovoitov 2015-03-25 278 };
2541517c32be253 Alexei Starovoitov 2015-03-25 279
:::::: The code at line 216 was first introduced by commit
:::::: 6ae08ae3dea2cfa03dd3665a3c8475c2d429ef47 bpf: Add probe_read_{user, kernel} and probe_read_{user, kernel}_str helpers
:::::: TO: Daniel Borkmann <daniel@...earbox.net>
:::::: CC: Alexei Starovoitov <ast@...nel.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (24527 bytes)
Powered by blists - more mailing lists