Re: [PATCH net-next 12/24] seg6: Use nested-BH locking for seg6_bpf_srh_states.

From: kernel test robot
Date: Fri Dec 15 2023 - 22:40:28 EST


Hi Sebastian,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url: https://github.com/intel-lab-lkp/linux/commits/Sebastian-Andrzej-Siewior/locking-local_lock-Introduce-guard-definition-for-local_lock/20231216-011911
base: net-next/main
patch link: https://lore.kernel.org/r/20231215171020.687342-13-bigeasy%40linutronix.de
patch subject: [PATCH net-next 12/24] seg6: Use nested-BH locking for seg6_bpf_srh_states.
config: x86_64-randconfig-r131-20231216 (https://download.01.org/0day-ci/archive/20231216/202312161151.k1MBvXUD-lkp@xxxxxxxxx/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231216/202312161151.k1MBvXUD-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312161151.k1MBvXUD-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> net/ipv6/seg6_local.c:1431:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct local_lock_t [usertype] *l @@ got struct local_lock_t [noderef] __percpu * @@
net/ipv6/seg6_local.c:1431:9: sparse: expected struct local_lock_t [usertype] *l
net/ipv6/seg6_local.c:1431:9: sparse: got struct local_lock_t [noderef] __percpu *

vim +1431 net/ipv6/seg6_local.c

1410
1411 static int input_action_end_bpf(struct sk_buff *skb,
1412 struct seg6_local_lwt *slwt)
1413 {
1414 struct seg6_bpf_srh_state *srh_state;
1415 struct ipv6_sr_hdr *srh;
1416 int ret;
1417
1418 srh = get_and_validate_srh(skb);
1419 if (!srh) {
1420 kfree_skb(skb);
1421 return -EINVAL;
1422 }
1423 advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
1424
1425 /* The access to the per-CPU buffer srh_state is protected by running
1426 * always in softirq context (with disabled BH). On PREEMPT_RT the
1427 * required locking is provided by the following local_lock_nested_bh()
1428 * statement. It is also accessed by the bpf_lwt_seg6_* helpers via
1429 * bpf_prog_run_save_cb().
1430 */
> 1431 scoped_guard(local_lock_nested_bh, &seg6_bpf_srh_states.bh_lock) {
1432 srh_state = this_cpu_ptr(&seg6_bpf_srh_states);
1433 srh_state->srh = srh;
1434 srh_state->hdrlen = srh->hdrlen << 3;
1435 srh_state->valid = true;
1436
1437 rcu_read_lock();
1438 bpf_compute_data_pointers(skb);
1439 ret = bpf_prog_run_save_cb(slwt->bpf.prog, skb);
1440 rcu_read_unlock();
1441
1442 switch (ret) {
1443 case BPF_OK:
1444 case BPF_REDIRECT:
1445 break;
1446 case BPF_DROP:
1447 goto drop;
1448 default:
1449 pr_warn_once("bpf-seg6local: Illegal return value %u\n", ret);
1450 goto drop;
1451 }
1452
1453 if (srh_state->srh && !seg6_bpf_has_valid_srh(skb))
1454 goto drop;
1455 }
1456
1457 if (ret != BPF_REDIRECT)
1458 seg6_lookup_nexthop(skb, NULL, 0);
1459
1460 return dst_input(skb);
1461
1462 drop:
1463 kfree_skb(skb);
1464 return -EINVAL;
1465 }
1466

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki