[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM_iQpURdiJv9GqkEyk=MPokacvtJVfHUpBb3=6EWA0e1yiTZQ@mail.gmail.com>
Date: Mon, 6 May 2019 21:54:59 -0700
From: Cong Wang <xiyou.wangcong@...il.com>
To: Jason Wang <jasowang@...hat.com>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
"Michael S. Tsirkin" <mst@...hat.com>,
YueHaibing <yuehaibing@...wei.com>,
"weiyongjun (A)" <weiyongjun1@...wei.com>,
Eric Dumazet <eric.dumazet@...il.com>
Subject: Re: [PATCH net V2] tuntap: synchronize through tfiles array instead
of tun->numqueues
On Mon, May 6, 2019 at 9:03 PM Jason Wang <jasowang@...hat.com> wrote:
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index e9ca1c0..32a0b23 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -700,6 +700,8 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
> tun->tfiles[tun->numqueues - 1]);
> ntfile = rtnl_dereference(tun->tfiles[index]);
> ntfile->queue_index = index;
> + rcu_assign_pointer(tun->tfiles[tun->numqueues - 1],
> + NULL);
>
How does this work? Existing readers could still read this
tun->tfiles[tun->numqueues - 1] before you NULL it. And,
_if_ the following sock_put() is the one frees it, you still miss
a RCU grace period.
if (clean) {
RCU_INIT_POINTER(tfile->tun, NULL);
sock_put(&tfile->sk);
Thanks.
Powered by blists - more mailing lists