Skip to content

net: backport netdevice and netns refcount tracking and enable them for debug kernels

Ivan Vecera requested to merge ivecera/centos-stream-9:bz2096377 into main

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2096377
Tested: Basic networking tasks using namespaces, vlans, veths, macvlans etc. with kernel-debug flavor

Upstream kernel recently introduces refcount tracking infrastructure for network devices and namespaces to help to avoid resource leaks and use-after-free issues. This infrastructure should be helpful for our support teams to debug customers' issues. The series backports the following commits and enables both trackers for kernel debug flavors:

95d1d2490c27 ("netdevice: move xdp_rxq within netdev_rx_queue")
2a12ae5d433d ("net: inline sock_prot_inuse_add()")
d477eb900484 ("net: make sock_inuse_add() available")
4199bae10c49 ("net: merge net->core.prot_inuse and net->core.sock_inuse")
b3cb764aa1d7 ("net: drop nopreempt requirement on sock_prot_inuse_add()")
4e66934eaadc ("lib: add reference counting tracking infrastructure")
914a7b5000d0 ("lib: add tests for reference tracker")
4d92b95ff2f9 ("net: add net device refcount tracker infrastructure")
80e8921b2b72 ("net: add net device refcount tracker to struct netdev_rx_queue")
0b688f24b7d6 ("net: add net device refcount tracker to struct netdev_queue")
5ae2195088d0 ("net: add net device refcount tracker to ethtool_phys_id()")
14ed029b5eb5 ("net: add net device refcount tracker to dev_ifsioc()")
4dbd24f65c60 ("drop_monitor: add net device refcount tracker")
9038c320001d ("net: dst: add net device refcount tracking to dst_entry")
fb67510ba9bd ("ipv6: add net device refcount tracker to rt6_probe_deferred()")
c0fd407a0666 ("sit: add net device refcount tracking to ip_tunnel")
56c1c77948ba ("ipv6: add net device refcount tracker to struct ip6_tnl")
85662c9f8cbd ("net: add net device refcount tracker to struct neighbour")
77a23b1f9543 ("net: add net device refcount tracker to struct pneigh_entry")
08d622568e5a ("net: add net device refcount tracker to struct neigh_parms")
f77159a348f2 ("net: add net device refcount tracker to struct netdev_adjacent")
8c727003c4d0 ("ipv6: add net device refcount tracker to struct inet6_dev")
c04438f58d14 ("ipv4: add net device refcount tracker to struct in_device")
606509f27f67 ("net/sched: add net device refcount tracker to struct Qdisc")
63f13937cbe9 ("net: linkwatch: add net device refcount tracker")
095e200f175f ("net: failover: add net device refcount tracker")
42120a864383 ("ipmr, ip6mr: add net device refcount tracker to struct vif_device")
5fa5ae605821 ("netpoll: add net device refcount tracker to struct netpoll")
c0e5e11af12b ("vrf: use dev_replace_track() for better tracking")
08f0b22d731f ("net: eql: add net device refcount tracker")
19c9ebf6ed70 ("vlan: add net device refcount tracker")
b2dcdc7f731d ("net: bridge: add net device refcount tracker")
f12bf6f3f942 ("net: watchdog: add net device refcount tracker")
4fc003fe0313 ("net: switchdev: add net device refcount tracker")
e44b14ebae10 ("inet: add net device refcount tracker to struct fib_nh_common")
66ce07f7802b ("ax25: add net device refcount tracker")
615d069dcf12 ("llc: add net device refcount tracker")
035f1f2b96ae ("pktgen add net device refcount tracker")
b60645248af3 ("net/smc: add net device tracker to struct smc_pnetentry")
e4b8954074f6 ("netlink: add net device refcount tracker to struct ethnl_req_info")
e7c8ab8419d7 ("openvswitch: add net device refcount tracker to struct vport")
ada066b2e02c ("net: sched: act_mirred: add net device refcount tracker")
4177e4960594 ("xfrm: use net device refcount tracker helpers")
9ba74e6c9e9d ("net: add networking namespace refcount tracker")
ffa84b5ffb37 ("net: add netns refcount tracker to struct sock")
04a931e58d19 ("net: add netns refcount tracker to struct seq_net_private")
dbdcda634ce3 ("net: sched: add netns refcount tracker to struct tcf_exts")
285ec2fef4b8 ("l2tp: add netns refcount tracker to l2tp_dfs_seq_data")
11b311a867b6 ("ppp: add netns refcount tracker")
0976b888a150 ("ethtool: fix null-ptr-deref on ref tracker")
e1b539bd73a7 ("xfrm: add net device refcount tracker to struct xfrm_state_offload")
8b40a9d53d4f ("ipv6: use GFP_ATOMIC in rt6_probe()")
1d2f3d3c6268 ("mptcp: adjust to use netns refcount tracker")
123e495ecc25 ("net: linkwatch: be more careful about dev->linkwatch_dev_tracker")
9280ac2e6f19 ("net: dev_replace_track() cleanup")
34ac17ecbf57 ("ethtool: use ethnl_parse_header_dev_put()")
f1d9268e0618 ("net: add net device refcount tracker to struct packet_type")
3bc14ea0d12a ("ethtool: always write dev in ethnl_parse_header_dev_get")
a9382d9389a0 ("netfilter: nfnetlink: add netns refcount tracker to struct nfulnl_instance")
30db406923b9 ("netfilter: nf_nat_masquerade: make async masq_inet6_event handling generic")
7970a19b7104 ("netfilter: nf_nat_masquerade: defer conntrack walk to work queue")
fc0d026a2fad ("netfilter: nf_nat_masquerade: add netns refcount tracker to masq_dev_work")
88248c357c2a ("net/sched: add missing tracker information in qdisc_create()")
2d6ec25539b0 ("netlink: do not allocate a device refcount tracker in ethnl_default_notify()")
bf44077c1b3a ("af_packet: fix tracking issues in packet_do_bind()")
cb963a19d99f ("net: sched: do not allocate a tracker in tcf_exts_init()")
c12837d1bb31 ("ref_tracker: use __GFP_NOFAIL more carefully")
fcfb894d5952 ("net: bridge: fix net device refcount tracking issue in error path")
7b9b1d449a7c ("net/smc: fix possible NULL deref in smc_pnet_add_eth()")
6cdef8a6ee74 ("SUNRPC: add netns refcount tracker to struct svc_xprt")
9b1831e56c7f ("SUNRPC: add netns refcount tracker to struct gss_auth")
b9a0d6d143ec ("SUNRPC: add netns refcount tracker to struct rpc_xprt")
e3ececfe668f ("ref_tracker: implement use-after-free detection")
8fd5522f44dc ("ref_tracker: add a count of untracked references")
4c6c11ea0f7b ("net: refine dev_put()/dev_hold() debugging")
28f922213886 ("net/smc: fix ref_tracker issue in smc_pnet_add()")
94fdd7c02a56 ("net/smc: use GFP_ATOMIC allocation in smc_pnet_add_eth()")
b2309a71c1f2 ("net: add dev->dev_registered_tracker")
3db09e762dc7 ("net/sched: cls_u32: fix netns refcount changes in u32_change()")
ec5b0f605b10 ("net/sched: cls_u32: fix possible leak in u32_init_knode()")

Signed-off-by: Ivan Vecera ivecera@redhat.com

Edited by Ivan Vecera

Merge request reports