vcc_connect() takes a reference on the atm_dev, and __vcc_connect() stores the device in vcc->dev together with a reference on dev->ops->owner. vcc_destroy_socket() drops both only when dev->ops->owner is non-NULL. usbatm and solos-pci set .owner to THIS_MODULE, which is NULL when they are built in, so in that configuration every connected PVC leaks one atm_dev reference on close. After atm_dev_deregister() the count then never reaches zero, so ->dev_close() is not called and the atm_dev, and for usbatm the driver instance, are never freed. The owner check was added so that static meta devices such as lecatm_dev and sigd_dev, which were attached without a reference, were not put. The last of them was removed by commit aa582dc25ace ("atm: remove SVC socket support and the signaling daemon interface"), and __vcc_connect() is now the only place that sets vcc->dev, always with a reference held. Drop the reference whenever vcc->dev is set. module_put(NULL) is a no-op, so modular drivers still get exactly one module_put() and one atm_dev_put() per close. Kernels before 7.2 still have the meta devices, so a backport there must keep skipping atm_dev_put() for them. Fixes: 93a2014afbac ("atm: fix a UAF in lec_arp_clear_vccs()") Cc: stable@vger.kernel.org # 7.2.x Signed-off-by: Yige Jiang --- Based on linux-next next-20261109 (630059a5a632). Compile-tested: arm64, GCC 14.2.0, W=1, defconfig + CONFIG_COMPILE_TEST=y, CONFIG_ATM=y (net/atm/common.o; no new warnings vs base). Runtime-tested in QEMU (arm64 virt, KASAN, kmemleak) on a model: a test module that registers an atm_dev with ops->owner == NULL stands in for a built-in driver. Before the patch each connect/close cycle leaves one more reference and the device is never released after deregistration; after it the count returns to 1 and the device is released. A device with ops->owner == THIS_MODULE sees no double put. No hardware test. Triggered by close() of a PF_ATMPVC socket that was connected to a usbatm or solos-pci device built into the kernel; the leak shows once the device is removed. Stable is limited to 7.2.x because before aa582dc25ace (v7.2-rc1) the static meta devices still reach vcc_destroy_socket() without a reference, and this change would put them. A real built-in usbatm or solos device (USB unplug) was not tested. net/atm/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/atm/common.c b/net/atm/common.c index 8119572..f68bf8d 100644 --- a/net/atm/common.c +++ b/net/atm/common.c @@ -184,7 +184,7 @@ static void vcc_destroy_socket(struct sock *sk) kfree_skb(skb); } - if (vcc->dev && vcc->dev->ops->owner) { + if (vcc->dev) { module_put(vcc->dev->ops->owner); atm_dev_put(vcc->dev); } base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47