Subject: Re: [PATCH net-next] netfilter: xt_owner: no longer acquire sk_callback_lock in mt_owner()

From: Florian Westphal <[email-masked]>
Date: Tue, 24 Feb 2026 16:49:33 +0100

Eric Dumazet <[email-masked]> wrote:
> Sure, I will remove the rcu_read_lock()/rcu_read_unlock()
> 
> Do you think adding lockdep_assert_in_rcu_read_lock() would be useful
> or would it be too much, iptables/nftables willl always be run under RCU
> and this is well understood ?

I don't think the lockdep assertion is needed; but I don't mind if you
add one.

All netfilter hooks run under rcu:

static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
                          struct sock *sk, struct sk_buff *skb,
                          struct net_device *indev, struct net_device *outdev,
                          int (*okfn)(struct net *, struct sock *, struct sk_buff *))
{
        struct nf_hook_entries *hook_head = NULL;
        int ret = 1;

	[..]

        rcu_read_lock();
        switch (pf) {
        case NFPROTO_IPV4:
                hook_head = rcu_dereference(net->nf.hooks_ipv4[hook]);
	[..]
	if (hook_head) {

                ret = nf_hook_slow(skb, &state, hook_head, 0);
        }
        rcu_read_unlock();
	[..]

Thanks Eric!