]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: pfcp: allocate per-cpu tstats for PFCP netdevs
authorSamuel Moelius <sam.moelius@trailofbits.com>
Tue, 9 Jun 2026 23:22:45 +0000 (23:22 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 11 Jun 2026 22:19:17 +0000 (15:19 -0700)
PFCP uses dev_get_tstats64() as its ndo_get_stats64 callback, but
pfcp_link_setup() does not request NETDEV_PCPU_STAT_TSTATS.  The net
core therefore leaves dev->tstats NULL for PFCP devices.

Creating a PFCP rtnetlink device can immediately ask the new netdev for
stats while building the RTM_NEWLINK notification.  That reaches
dev_get_tstats64() and dereferences the NULL dev->tstats pointer.

Set pcpu_stat_type to NETDEV_PCPU_STAT_TSTATS during PFCP link setup so
the net core allocates the storage expected by dev_get_tstats64().

Fixes: 76c8764ef36a ("pfcp: add PFCP module")
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Link: https://patch.msgid.link/20260609232244.1602027.c569f6c530f6.pfcp-missing-tstats-link-create-oops@trailofbits.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/pfcp.c

index 28e6bc4a1f14c801259e7e9adf6c682ac1aaa628..a6aa30ae0af76243e28d3723753fcdcd34328ed1 100644 (file)
@@ -148,6 +148,7 @@ static void pfcp_link_setup(struct net_device *dev)
        dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
        dev->priv_flags |= IFF_NO_QUEUE;
 
+       dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
        netif_keep_dst(dev);
 }