Re: [PATCH] net: Fix suspicious RCU usage in bpf_sk_reuseport_detach()

From: David Howells
Date: Tue Aug 16 2022 - 17:17:46 EST


Hawkins Jiawei <yin31149@xxxxxxxxx> wrote:

> +__rcu_dereference_sk_user_data_with_flags_check(const struct sock *sk,
> + uintptr_t flags, bool condition)

That doesn't work. RCU_LOCKDEP_WARN() relies on anything passing on a
condition down to it to be a macro so that it can vanish the 'condition'
argument without causing an undefined symbol for 'lockdep_is_held' if lockdep
is disabled:

x86_64-linux-gnu-ld: kernel/bpf/reuseport_array.o: in function `bpf_sk_reuseport_detach':
/data/fs/linux-fs/build3/../kernel/bpf/reuseport_array.c:28: undefined reference to `lockdep_is_held'

So either __rcu_dereference_sk_user_data_with_flags_check() has to be a macro,
or we need to go with something like the first version of my patch where I
don't pass the condition through. Do you have a preference?

David