[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202304260539.vm2qQLzo-lkp@intel.com>
Date: Wed, 26 Apr 2023 05:44:57 +0800
From: kernel test robot <lkp@...el.com>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: oe-kbuild-all@...ts.linux.dev,
"Gustavo A. R. Silva" <gustavo@...eddedor.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: [gustavoars:testing/fsfa3-next-20230425 1/1]
kernel/bpf/net_namespace.c:437:27: warning: array subscript [0, 1] is
outside array bounds of 'struct bpf_prog *[2]'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git testing/fsfa3-next-20230425
head: b82a35ff486df1d6737f532e08e060c466f9e652
commit: b82a35ff486df1d6737f532e08e060c466f9e652 [1/1] Makefile: Enable -Wstringop-overflow and -Warray-bounds
config: microblaze-randconfig-r002-20230424 (https://download.01.org/0day-ci/archive/20230426/202304260539.vm2qQLzo-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/commit/?id=b82a35ff486df1d6737f532e08e060c466f9e652
git remote add gustavoars https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git
git fetch --no-tags gustavoars testing/fsfa3-next-20230425
git checkout b82a35ff486df1d6737f532e08e060c466f9e652
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=microblaze olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=microblaze SHELL=/bin/bash kernel/bpf/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304260539.vm2qQLzo-lkp@intel.com/
All warnings (new ones prefixed by >>):
kernel/bpf/net_namespace.c: In function 'netns_bpf_link_attach':
>> kernel/bpf/net_namespace.c:437:27: warning: array subscript [0, 1] is outside array bounds of 'struct bpf_prog *[2]' [-Warray-bounds]
437 | if (net->bpf.progs[type]) {
| ~~~~~~~~~~~~~~^~~~~~
In file included from include/linux/bpf-netns.h:6,
from kernel/bpf/net_namespace.c:4:
include/net/netns/bpf.h:24:26: note: while referencing 'progs'
24 | struct bpf_prog *progs[MAX_NETNS_BPF_ATTACH_TYPE];
| ^~~~~
vim +437 kernel/bpf/net_namespace.c
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 420
7f045a49fee04b Jakub Sitnicki 2020-05-31 421 static int netns_bpf_link_attach(struct net *net, struct bpf_link *link,
7f045a49fee04b Jakub Sitnicki 2020-05-31 422 enum netns_bpf_attach_type type)
7f045a49fee04b Jakub Sitnicki 2020-05-31 423 {
ab53cad90eb10c Jakub Sitnicki 2020-06-25 424 struct bpf_netns_link *net_link =
ab53cad90eb10c Jakub Sitnicki 2020-06-25 425 container_of(link, struct bpf_netns_link, link);
695c12147a4018 Jakub Sitnicki 2020-06-25 426 struct bpf_prog_array *run_array;
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 427 int cnt, err;
7f045a49fee04b Jakub Sitnicki 2020-05-31 428
7f045a49fee04b Jakub Sitnicki 2020-05-31 429 mutex_lock(&netns_bpf_mutex);
7f045a49fee04b Jakub Sitnicki 2020-05-31 430
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 431 cnt = link_count(net, type);
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 432 if (cnt >= netns_bpf_max_progs(type)) {
7f045a49fee04b Jakub Sitnicki 2020-05-31 433 err = -E2BIG;
7f045a49fee04b Jakub Sitnicki 2020-05-31 434 goto out_unlock;
7f045a49fee04b Jakub Sitnicki 2020-05-31 435 }
7f045a49fee04b Jakub Sitnicki 2020-05-31 436 /* Links are not compatible with attaching prog directly */
695c12147a4018 Jakub Sitnicki 2020-06-25 @437 if (net->bpf.progs[type]) {
7f045a49fee04b Jakub Sitnicki 2020-05-31 438 err = -EEXIST;
7f045a49fee04b Jakub Sitnicki 2020-05-31 439 goto out_unlock;
7f045a49fee04b Jakub Sitnicki 2020-05-31 440 }
7f045a49fee04b Jakub Sitnicki 2020-05-31 441
7f045a49fee04b Jakub Sitnicki 2020-05-31 442 switch (type) {
7f045a49fee04b Jakub Sitnicki 2020-05-31 443 case NETNS_BPF_FLOW_DISSECTOR:
3b7016996c4c44 Jakub Sitnicki 2020-06-25 444 err = flow_dissector_bpf_prog_attach_check(net, link->prog);
7f045a49fee04b Jakub Sitnicki 2020-05-31 445 break;
e9ddbb7707ff58 Jakub Sitnicki 2020-07-17 446 case NETNS_BPF_SK_LOOKUP:
e9ddbb7707ff58 Jakub Sitnicki 2020-07-17 447 err = 0; /* nothing to check */
e9ddbb7707ff58 Jakub Sitnicki 2020-07-17 448 break;
7f045a49fee04b Jakub Sitnicki 2020-05-31 449 default:
7f045a49fee04b Jakub Sitnicki 2020-05-31 450 err = -EINVAL;
7f045a49fee04b Jakub Sitnicki 2020-05-31 451 break;
7f045a49fee04b Jakub Sitnicki 2020-05-31 452 }
7f045a49fee04b Jakub Sitnicki 2020-05-31 453 if (err)
7f045a49fee04b Jakub Sitnicki 2020-05-31 454 goto out_unlock;
7f045a49fee04b Jakub Sitnicki 2020-05-31 455
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 456 run_array = bpf_prog_array_alloc(cnt + 1, GFP_KERNEL);
695c12147a4018 Jakub Sitnicki 2020-06-25 457 if (!run_array) {
695c12147a4018 Jakub Sitnicki 2020-06-25 458 err = -ENOMEM;
695c12147a4018 Jakub Sitnicki 2020-06-25 459 goto out_unlock;
695c12147a4018 Jakub Sitnicki 2020-06-25 460 }
695c12147a4018 Jakub Sitnicki 2020-06-25 461
ab53cad90eb10c Jakub Sitnicki 2020-06-25 462 list_add_tail(&net_link->node, &net->bpf.links[type]);
7f045a49fee04b Jakub Sitnicki 2020-05-31 463
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 464 fill_prog_array(net, type, run_array);
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 465 run_array = rcu_replace_pointer(net->bpf.run_array[type], run_array,
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 466 lockdep_is_held(&netns_bpf_mutex));
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 467 bpf_prog_array_free(run_array);
ce3aa9cc510936 Jakub Sitnicki 2020-07-17 468
1559b4aa1db443 Jakub Sitnicki 2020-07-17 469 /* Mark attach point as used */
1559b4aa1db443 Jakub Sitnicki 2020-07-17 470 netns_bpf_attach_type_need(type);
1559b4aa1db443 Jakub Sitnicki 2020-07-17 471
7f045a49fee04b Jakub Sitnicki 2020-05-31 472 out_unlock:
7f045a49fee04b Jakub Sitnicki 2020-05-31 473 mutex_unlock(&netns_bpf_mutex);
7f045a49fee04b Jakub Sitnicki 2020-05-31 474 return err;
7f045a49fee04b Jakub Sitnicki 2020-05-31 475 }
7f045a49fee04b Jakub Sitnicki 2020-05-31 476
:::::: The code at line 437 was first introduced by commit
:::::: 695c12147a40181fe9221d321c3f2de33c9574ed bpf, netns: Keep attached programs in bpf_prog_array
:::::: TO: Jakub Sitnicki <jakub@...udflare.com>
:::::: CC: Alexei Starovoitov <ast@...nel.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Powered by blists - more mailing lists