Subject: Re: [BUG] kernel warning from br_nf_local_in+0x157/0x180

From: Pablo Neira Ayuso <[email-masked]>
Date: Fri, 22 Mar 2024 13:27:46 +0100

Hi Jianbo,

On Mon, Mar 18, 2024 at 09:41:46AM +0000, Jianbo Liu wrote:
> Hi Florian and Pablo,
> 
> We hit the following warning from br_nf_local_in+0x157/0x180.

Can you give a try to this patch?

This fix is not yet complete but it should fix the splat for this
test.

Thanks.
diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
index 35e10c5a766d..085d3f751b3f 100644
--- a/net/bridge/br_netfilter_hooks.c
+++ b/net/bridge/br_netfilter_hooks.c
@@ -612,6 +612,13 @@ static unsigned int br_nf_local_in(void *priv,
 	if (likely(nf_ct_is_confirmed(ct)))
 		return NF_ACCEPT;
 
+	if (skb->pkt_type != PACKET_BROADCAST &&
+	    skb->pkt_type != PACKET_MULTICAST) {
+		skb->_nfct = 0ul;
+		nf_conntrack_put(nfct);
+		return NF_ACCEPT;
+	}
+
 	WARN_ON_ONCE(skb_shared(skb));
 	WARN_ON_ONCE(refcount_read(&nfct->use) != 1);