Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751763AbdG1Dqq (ORCPT ); Thu, 27 Jul 2017 23:46:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48948 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751719AbdG1Dqm (ORCPT ); Thu, 27 Jul 2017 23:46:42 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A98EFC104211 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mst@redhat.com Date: Fri, 28 Jul 2017 06:46:40 +0300 From: "Michael S. Tsirkin" To: Jason Wang Cc: Jakub Kicinski , davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 3/3] tap: XDP support Message-ID: <20170728064603-mutt-send-email-mst@kernel.org> References: <1501147533-12368-1-git-send-email-jasowang@redhat.com> <1501147533-12368-4-git-send-email-jasowang@redhat.com> <20170727201338.65d56b2a@cakuba.netronome.com> <7d1cb7bf-43c1-3993-be00-04e4676dd917@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7d1cb7bf-43c1-3993-be00-04e4676dd917@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 28 Jul 2017 03:46:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 562 Lines: 13 On Fri, Jul 28, 2017 at 11:28:54AM +0800, Jason Wang wrote: > > > + old_prog = rtnl_dereference(tun->xdp_prog); > > > + if (old_prog) > > > + bpf_prog_put(old_prog); > > > + rcu_assign_pointer(tun->xdp_prog, prog); > > Is this OK? Could this lead to the program getting freed and then > > datapath accessing a stale pointer? I mean in the scenario where the > > process gets pre-empted between the bpf_prog_put() and > > rcu_assign_pointer()? > > Will call bpf_prog_put() after rcu_assign_pointer(). I suspect you need to sync RCU or something before that.