From: Andrey Misiurov <amisiurov@cloudlinux.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Wojciech Drewek <wojciech.drewek@intel.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Andrey Misiurov <amisiurov@cloudlinux.com>
Subject: [PATCH net] pfcp: drop packets until the device is initialised
Date: Thu, 19 Nov 2026 13:29:46 +0100 [thread overview]
Message-ID: <20261119122946.1720693-1-amisiurov@cloudlinux.com> (raw)
pfcp_newlink() creates the PFCP UDP socket (port 8805) and publishes it
(sk_user_data = pfcp, encap_rcv = pfcp_encap_recv) before
register_netdevice() runs ndo_init, which is where pfcp->dev is set. A
datagram that arrives in that window passes the "pfcp != NULL" check in
pfcp_encap_recv() and then dereferences a NULL pfcp->dev:
BUG: kernel NULL pointer dereference, address: 0000000000000108
#PF: supervisor read access in kernel mode
Oops: 0000 [#1] SMP PTI
CPU: 0 PID: 26516 Comm: pfcp_race
RIP: 0010:pfcp_encap_recv+0xeb/0x1d0 [pfcp]
Call Trace:
<IRQ>
udp_queue_rcv_one_skb+0x24a/0x560
udp_queue_rcv_skb+0x4f/0x80
udp_unicast_rcv_skb+0x78/0xa0
__udp4_lib_rcv+0x519/0x5f0
udp_rcv+0x25/0x40
ip_protocol_deliver_rcu+0xd4/0x210
ip_local_deliver_finish+0x86/0x110
ip_local_deliver+0x65/0x110
ip_rcv+0x17d/0x190
__netif_receive_skb_one_core+0x8d/0xa0
The window is wide when register_netdevice() fails before ndo_init (e.g. an
invalid name): the socket stays live until pfcp_del_sock() on the error
path. A narrower window also exists on the normal success path.
Drop the packet while pfcp->dev is not yet set or the device is not
running.
Fixes: 76c8764ef36a ("pfcp: add PFCP module")
Signed-off-by: Andrey Misiurov <amisiurov@cloudlinux.com>
---
Found during a backport review.
Reproduced on ubuntu-resolute 7.0.0-42: flood UDP :8805 while creating a
pfcp link with an invalid name (register_netdevice() fails before ndo_init)
-> the NULL-deref above (kdump vmcore). With the fix the same run stays clean.
drivers/net/pfcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/pfcp.c b/drivers/net/pfcp.c
--- a/drivers/net/pfcp.c
+++ b/drivers/net/pfcp.c
@@ -61,7 +61,7 @@
goto drop;
pfcp = rcu_dereference_sk_user_data(sk);
- if (unlikely(!pfcp))
+ if (unlikely(!pfcp || !pfcp->dev || !netif_running(pfcp->dev)))
goto drop;
unparsed = pfcp_hdr(skb);
next reply other threads:[~2026-11-19 12:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 12:29 Andrey Misiurov [this message]
2026-11-28 14:15 ` [PATCH net] pfcp: drop packets until the device is initialised Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119122946.1720693-1-amisiurov@cloudlinux.com \
--to=amisiurov@cloudlinux.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wojciech.drewek@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.