From: Yanjun Zhu Subject: Re: [PATCH] net: nvidia: forcedeth: Fix two possible concurrency use-after-free bugs Date: Wed, 9 Jan 2019 09:24:48 +0800 Message-ID: References: <20190108124518.21986-1-baijiaju1990@gmail.com> <27392ae0-2c0f-f099-05d8-f9cdbfbd313e@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: Jia-Ju Bai , davem@davemloft.net, keescook@chromium.org Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On 2019/1/8 20:57, Jia-Ju Bai wrote: > > > On 2019/1/8 20:54, Zhu Yanjun wrote: >> >> 在 2019/1/8 20:45, Jia-Ju Bai 写道: >>> In drivers/net/ethernet/nvidia/forcedeth.c, the functions >>> nv_start_xmit() and nv_start_xmit_optimized() can be concurrently >>> executed with nv_poll_controller(). >>> >>> nv_start_xmit >>>    line 2321: prev_tx_ctx->skb = skb; >>> >>> nv_start_xmit_optimized >>>    line 2479: prev_tx_ctx->skb = skb; >>> >>> nv_poll_controller >>>    nv_do_nic_poll >>>      line 4134: spin_lock(&np->lock); >>>      nv_drain_rxtx >>>        nv_drain_tx >>>          nv_release_txskb >>>            line 2004: dev_kfree_skb_any(tx_skb->skb); >>> >>> Thus, two possible concurrency use-after-free bugs may occur. >>> >>> To fix these possible bugs, >> >> >> Does this really occur? Can you reproduce this ? > > This bug is not found by the real execution. > It is found by a static tool written by myself, and then I check it by > manual code review. Before "line 2004: dev_kfree_skb_any(tx_skb->skb); ", "                 nv_disable_irq(dev);                 nv_napi_disable(dev);                 netif_tx_lock_bh(dev);                 netif_addr_lock(dev);                 spin_lock(&np->lock);                 /* stop engines */                 nv_stop_rxtx(dev);   <---this stop rxtx                 nv_txrx_reset(dev); " In this case, does nv_start_xmit or nv_start_xmit_optimized still work well? Zhu Yanjun > > > Best wishes, > Jia-Ju Bai