FAILED: patch "[PATCH] net: avoid UAF on deleted altname" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 1a83f4a7c156fa6bbd6b530e89fa3270bf3d9d1b
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023102011-rubble-require-8127@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 1a83f4a7c156fa6bbd6b530e89fa3270bf3d9d1b Mon Sep 17 00:00:00 2001
From: Jakub Kicinski <[email protected]>
Date: Tue, 17 Oct 2023 18:38:15 -0700
Subject: [PATCH] net: avoid UAF on deleted altname
Altnames are accessed under RCU (dev_get_by_name_rcu()) but freed by kfree() with no synchronization point.
Each node has one or two allocations (node and a variable-size name, sometimes the name is netdev->name). Adding rcu_heads here is a bit tedious. Besides most code which unlists the names already has rcu barriers - so take the simpler approach of adding synchronize_rcu(). Note that the one on the unregistration path (which matters more) is removed by the next fix.
net/core/dev.c +6 -1
@@ -345,7 +345,6 @@ int netdev_name_node_alt_create(struct net_device *dev, const char *name)static void __netdev_name_node_alt_destroy (struct netdev_name_node *name_node) {list_del (&name_node->list); -netdev_name_node_del (name_node);kfree (name_node->name);netdev_name_node_free (name_node); }
@@ -364,6 +363,8 @@ int netdev_name_node_alt_destroy(struct net_device *dev, const char *name)if (name_node == dev->name_node || name_node->dev != dev)return -EINVAL ; +netdev_name_node_del (name_node); +synchronize_rcu ();__netdev_name_node_alt_destroy (name_node);return 0 ;
@@ -10941,6 +10942,7 @@ void unregister_netdevice_many_notify(struct list_head *head,synchronize_net ();list_for_each_entry (dev, head, unreg_list) { +struct netdev_name_node *name_node;struct sk_buff *skb =NULL ;/* Shutdown queueing discipline. */
@@ -10968,6 +10970,9 @@ void unregister_netdevice_many_notify(struct list_head *head,dev_uc_flush (dev);dev_mc_flush (dev); +netdev_for_each_altname (dev, name_node) +netdev_name_node_del (name_node); +synchronize_rcu ();netdev_name_node_alt_flush (dev);netdev_name_node_free (dev->name_node);