[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1385047624.10637.48.camel@edumazet-glaptop2.roam.corp.google.com>
Date: Thu, 21 Nov 2013 07:27:04 -0800
From: Eric Dumazet <eric.dumazet@...il.com>
To: Daniel Borkmann <dborkman@...hat.com>
Cc: davem@...emloft.net, netdev@...r.kernel.org,
Salam Noureddine <noureddine@...stanetworks.com>,
Ben Greear <greearb@...delatech.com>
Subject: Re: [PATCH net v2] packet: fix use after free race in send path
when dev is released
On Thu, 2013-11-21 at 16:02 +0100, Daniel Borkmann wrote:
>
> That was also my first thought, but Salam pointed out to me, that in case
> we have a situation such as ...
>
> in packet_cached_dev_get():
> rcu_read_lock();
> dev = rcu_dereference(po->cached_dev); in packet_notifier():
> ---> CPU1: dev_put(po->prot_hook.dev);
> ---> CPU0:
> if (dev)
> dev_hold(dev);
> rcu_read_unlock();
>
> ... we could reach a refcount of 0, before we increase it back to 1. Not sure
> if this can actually happen, maybe in preemptible RCU where read-side critical
> sections to be preempted? So with this rather paranoid approach we make sure
> to avoid such a situation as we wait a grace period when readers finished.
There is no need, because we respect a rcu grace period at dismantle
time already.
Nothing bad can happen inside the rcu_read_lock()/rcu_read_unlock() pair
in packed_cached_dev_get()
Note that dev_put() does not take any immediate action, it only
decrements the refcount.
So if CPU1 does the dev_put(po->prot_hook.dev) after
setting cached_dev to NULL, we should be safe.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists