Skip to content

Commit

Permalink
Squash to "bpf: Add bpf_mptcp_sched_ops"
Browse files Browse the repository at this point in the history
Similar to the previous commit, this splat can be seen:

  =============================
  WARNING: suspicious RCU usage
  6.12.0-rc2+ #1 Tainted: G           OE
  -----------------------------
  net/mptcp/sched.c:44 RCU-list traversed in non-reader section!!

  other info that might help us debug this:

  rcu_scheduler_active = 2, debug_locks = 1
  1 lock held by test_progs/323:
  ffff888007e16a40 (&st_map->lock){+.+.}-{3:3}, at: bpf_struct_ops_map_update_elem (kernel/bpf/bpf_struct_ops.c:632)

  stack backtrace:
  CPU: 0 UID: 0 PID: 323 Comm: test_progs Tainted: G           OE      6.12.0-rc2+ #1
  Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
  Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
  Call Trace:
   <TASK>
   dump_stack_lvl (lib/dump_stack.c:123)
   lockdep_rcu_suspicious (kernel/locking/lockdep.c:6822)
   mptcp_sched_find (net/mptcp/sched.c:44 (discriminator 7))
   bpf_mptcp_sched_init_member (net/mptcp/bpf.c:128 net/mptcp/bpf.c:109)
   ? btf_type_resolve_ptr (include/linux/btf.h:252 kernel/bpf/btf.c:637)
   bpf_struct_ops_map_update_elem (kernel/bpf/bpf_struct_ops.c:658)
   ? __might_fault (mm/memory.c:6700 (discriminator 5) mm/memory.c:6693 (discriminator 5))
   ? __pfx_bpf_struct_ops_map_update_elem (kernel/bpf/bpf_struct_ops.c:591)
   ? __pfx___might_resched (kernel/sched/core.c:8593)
   ? kasan_save_track (arch/x86/include/asm/current.h:49 (discriminator 1) mm/kasan/common.c:60 (discriminator 1) mm/kasan/common.c:69 (discriminator 1))
   bpf_map_update_value (kernel/bpf/syscall.c:169)
   map_update_elem (kernel/bpf/syscall.c:1627)
   ? __pfx_map_update_elem (kernel/bpf/syscall.c:1586)
   __sys_bpf (kernel/bpf/syscall.c:5622)
   ? __pfx___sys_bpf (kernel/bpf/syscall.c:5596)
   __x64_sys_bpf (kernel/bpf/syscall.c:5739)
   ? lockdep_hardirqs_on_prepare (kernel/locking/lockdep.c:4347 kernel/locking/lockdep.c:4406)
   do_syscall_64 (arch/x86/entry/common.c:52 (discriminator 1) arch/x86/entry/common.c:83 (discriminator 1))
   entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)

Also similar to the previous commit, this can be fixed by adding the
missing rcu_read_lock().

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
  • Loading branch information
matttbe authored and intel-lab-lkp committed Oct 16, 2024
1 parent 013c87b commit 07725f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/mptcp/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ static int bpf_mptcp_sched_init_member(const struct btf_type *t,
const struct mptcp_sched_ops *usched;
struct mptcp_sched_ops *sched;
u32 moff;
int ret;

usched = (const struct mptcp_sched_ops *)udata;
sched = (struct mptcp_sched_ops *)kdata;
Expand All @@ -123,9 +124,12 @@ static int bpf_mptcp_sched_init_member(const struct btf_type *t,
if (bpf_obj_name_cpy(sched->name, usched->name,
sizeof(sched->name)) <= 0)
return -EINVAL;
if (mptcp_sched_find(usched->name))
return -EEXIST;
return 1;

rcu_read_lock();
ret = mptcp_sched_find(usched->name) ? -EEXIST : 1;
rcu_read_unlock();

return ret;
}

return 0;
Expand Down

0 comments on commit 07725f4

Please sign in to comment.