Thread (1 message) 1 message, 1 author, 2022-11-21

Re: [PATCH v2] net: tun: Fix use-after-free in tun_detach()

From: Eric Dumazet <edumazet@google.com>
Date: 2022-11-21 00:54:36
Also in: lkml

On Sun, Nov 20, 2022 at 4:34 PM Hillf Danton [off-list ref] wrote:
On 20 Nov 2022 08:04:13 -0800 Eric Dumazet [off-list ref]
quoted
On Sun, Nov 20, 2022 at 2:49 AM Hillf Danton [off-list ref] wrote:
quoted
On 20 Nov 2022 18:02:13 +0900 Shigeru Yoshida [off-list ref]
quoted
This patch fixes the issue by calling sock_put() from tun_detach()
after all necessary accesses for the struct net has done.
Thanks for your fix.

But tun is not special wrt netdev_run_todo() and call_netdevice_notifiers(),
so the correct fix should be making netdev grab another hold on net and
invoking put_net() in the path of netdev_run_todo().
Well, this is not going to work. Unless I am missing something.
Thanks for taking a look.

I mean bump up refcount for net when updating netdev->nd_net in a bid to
make dev_net() safe throught netdev's life span.
This would prevent netns deletion, as the following sequence would
then no longer work as intended.

ip netns add foo
ip netns add ip link set lo up
ip netns del foo

When a netns is deleted ("ip netns del" and no more refcounted sockets),
we have callbacks to unregister all devices tied to it.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help