From: Jakub Kicinski Date: Wed, 22 May 2019 02:02:02 +0000 (-0700) Subject: net/tls: don't ignore netdev notifications if no TLS features X-Git-Tag: v4.19.48~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb6cf4f3704b6f058f312a6d228c56698313e1fa;p=platform%2Fkernel%2Flinux-rpi3.git net/tls: don't ignore netdev notifications if no TLS features [ Upstream commit c3f4a6c39cf269a40d45f813c05fa830318ad875 ] On device surprise removal path (the notifier) we can't bail just because the features are disabled. They may have been enabled during the lifetime of the device. This bug leads to leaking netdev references and use-after-frees if there are active connections while device features are cleared. Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure") Signed-off-by: Jakub Kicinski Reviewed-by: Dirk van der Merwe Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 5db330d..8035bf4 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -974,7 +974,8 @@ static int tls_dev_event(struct notifier_block *this, unsigned long event, { struct net_device *dev = netdev_notifier_info_to_dev(ptr); - if (!(dev->features & (NETIF_F_HW_TLS_RX | NETIF_F_HW_TLS_TX))) + if (!dev->tlsdev_ops && + !(dev->features & (NETIF_F_HW_TLS_RX | NETIF_F_HW_TLS_TX))) return NOTIFY_DONE; switch (event) {