From: Simon Horman <horms@kernel.org>
To: Andrey Misiurov <amisiurov@cloudlinux.com>
Cc: 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>,
Wojciech Drewek <wojciech.drewek@intel.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] pfcp: drop packets until the device is initialised
Date: Sat, 28 Nov 2026 14:15:57 +0000 [thread overview]
Message-ID: <20261128141557.GF31322@horms.kernel.org> (raw)
In-Reply-To: <20261119122946.1720693-1-amisiurov@cloudlinux.com>
On Thu, Nov 19, 2026 at 01:29:46PM +0100, Andrey Misiurov wrote:
> 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.
Reviewed-by: Simon Horman <horms@kernel.org>
prev parent reply other threads:[~2026-11-28 14:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 12:29 [PATCH net] pfcp: drop packets until the device is initialised Andrey Misiurov
2026-11-28 14:15 ` Simon Horman [this message]
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=20261128141557.GF31322@horms.kernel.org \
--to=horms@kernel.org \
--cc=amisiurov@cloudlinux.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@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.