[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231017075259.5876c644@kernel.org>
Date: Tue, 17 Oct 2023 07:52:59 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Jiri Pirko <jiri@...nulli.us>
Cc: davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
pabeni@...hat.com
Subject: Re: [PATCH net 3/5] net: avoid UAF on deleted altname
On Tue, 17 Oct 2023 09:51:02 +0200 Jiri Pirko wrote:
> >but freed by kfree() with no synchronization point.
> >
> >Because the name nodes don't hold a reference on the netdevice
> >either, take the heavier approach of inserting synchronization
>
> What about to use kfree_rcu() in netdev_name_node_free()
> and treat node_name->dev as a rcu pointer instead?
>
> struct net_device *dev_get_by_name_rcu(struct net *net, const char *name)
> {
> struct netdev_name_node *node_name;
>
> node_name = netdev_name_node_lookup_rcu(net, name);
> return node_name ? rcu_deferecence(node_name->dev) : NULL;
> }
>
> This would avoid synchronize_rcu() in netdev_name_node_alt_destroy()
>
> Btw, the next patch is smooth with this.
As I said in the commit message, I prefer the explicit sync.
Re-inserting the device and taking refs already necessitate it.
Powered by blists - more mailing lists