Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755215AbcJTSDG (ORCPT ); Thu, 20 Oct 2016 14:03:06 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:43926 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753366AbcJTSDE (ORCPT ); Thu, 20 Oct 2016 14:03:04 -0400 Date: Thu, 20 Oct 2016 14:03:00 -0400 (EDT) Message-Id: <20161020.140300.122827393647670926.davem@davemloft.net> To: vkuznets@redhat.com Cc: sthemmin@microsoft.com, netdev@vger.kernel.org, devel@linuxdriverproject.org, linux-kernel@vger.kernel.org, kys@microsoft.com, haiyangz@microsoft.com Subject: Re: [PATCH net-next] hv_netvsc: fix a race between netvsc_send() and netvsc_init_buf() From: David Miller In-Reply-To: <8737jr1k07.fsf@vitty.brq.redhat.com> References: <1476885181-3456-1-git-send-email-vkuznets@redhat.com> <8737jr1k07.fsf@vitty.brq.redhat.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Thu, 20 Oct 2016 11:03:03 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 640 Lines: 16 From: Vitaly Kuznetsov Date: Thu, 20 Oct 2016 10:51:04 +0200 > Stephen Hemminger writes: > >> Do we need ACCESS_ONCE() here to avoid check/use issues? >> > > I think we don't: this is the only place in the function where we read > the variable so we'll get normal read. We're not trying to syncronize > with netvsc_init_buf() as that would require locking, if we read stale > NULL value after it was already updated on a different CPU we're fine, > we'll just return -EAGAIN. The concern is if we race with netvsc_destroy_buf() and this pointer becomes NULL after the test you are adding.