Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp554094imm; Fri, 5 Oct 2018 08:05:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV62q6a6Fsz0s90tsKr1fYWG6OsBpPJL4N35np12c5bTF9LkV0NTyKSd0KRTQEtOeU7aa0ZOr X-Received: by 2002:a62:36c3:: with SMTP id d186-v6mr5748670pfa.133.1538751923029; Fri, 05 Oct 2018 08:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538751923; cv=none; d=google.com; s=arc-20160816; b=X6z9aVH9H8GLn6V0pc1E2g8q1aaWks1JpyKY+dP8qE1MPkweKEcVWUZGYTgZs2C+WB dVxR2nOePS+xj3ER/pRSiBhdu3q8fmidDNO2xZHsJkLHdmDmAKG7aXPUr2lmz7my2XMd b5s3sJf32txfkEUfsPatbm8vVcojrU9cK86Q1J8A08qRe+XhrOip4iBGdjoT+wxYh/J3 +irqiPPZ/EayPW/LXZfp7HEYiSBfG0iK9qP8Ft32LGKd7n/l/vrxiINGAtz2/BNI9Ub1 zetv4z1IwM8ofRX1ramK6tyRsi0hsLDSLsDr9A9Jz5h77H6npi5GtsSNCyYHWoShZ9T1 NOvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=L/TGPCGSyUrT/8gFsZlyhFkXi+cNNxbeGkSvNpmrstY=; b=l3z698Zr2kazRh39lB17pxHkMQPhvTvOuqitzbZdVt39WGpTTJVIKG7bsZfIK+rWZM JBFi/ymlGTjcCOVKYsju4Kgl6uP5xUdw6FcJE0IiaduC/1jykXFN78AQJB+SmtnOG/pm Yq5kGmYRGKvQu1KWkpoPM8+/jEQ5dbFnkmNSqHuCQLRoWKIiAdFDbsfSp8qCCOGgim1a MM+evUBI75IwLqfPvLfNZcxdeS5CYzuaA4I5LBsH1LHe9+POEACZo+2TLAqWpIosXsUz XMpH89jqqAwDJDlsc5bBsaBV0cMWJ9zYctJXi8phr05KZPRN/TLHaWRyFBJ1StA3M9IS 1kfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m66-v6si1044578pfm.191.2018.10.05.08.05.07; Fri, 05 Oct 2018 08:05:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728147AbeJEWD6 (ORCPT + 99 others); Fri, 5 Oct 2018 18:03:58 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:38463 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeJEWD5 (ORCPT ); Fri, 5 Oct 2018 18:03:57 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1g8Ren-0002aT-46; Fri, 05 Oct 2018 17:04:45 +0200 Date: Fri, 5 Oct 2018 17:04:45 +0200 From: Sebastian Andrzej Siewior To: Jia-Ju Bai Cc: klassert@kernel.org, davem@davemloft.net, anna-maria@linutronix.de, nhorman@tuxdriver.com, keescook@chromium.org, netdev@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [REPORT] net: 3com: 3c59x: Possible data races Message-ID: <20181005150444.pe46gjvd4434xfso@linutronix.de> References: <412162cd-8fab-104b-ce73-6f70f108218f@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <412162cd-8fab-104b-ce73-6f70f108218f@gmail.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-10-03 21:52:14 [+0800], Jia-Ju Bai wrote: > ****** Possible race0 ****** > CPU0: > vortex_boomerang_interrupt > line 2510: spin_lock_irqsave() > _boomerang_interrupt > line 2432: vp->tx_skbuff[entry] [READ] > line 2433: vp->tx_skbuff[entry] [READ] > line 2453: vp->tx_skbuff[entry] = NULL [WRITE] > > CPU1: > boomerang_start_xmit > line 2145: vp->tx_skbuff[entry] = skb [WRITE] > > As for vp->tx_skbuff[entry], the WRITE and READ operations in CPU0 > are performed with holding a spinlock, but the WRITE operation in CPU1 > is performed without holding this spinlock, so there may exist data races. not really. One side fills the ring buffer (cur_tx++) and the other side purges it (dirty_tx++). Don't see a overlap here. > ****** Possible race1 ****** > CPU0: > vortex_boomerang_interrupt > line 2510: spin_lock_irqsave() > _boomerang_interrupt > line 2421: vp->dirty_tx = dirty_tx [WRITE] > > CPU1: > boomerang_start_xmit > line 2137: vp->dirty_tx [READ] > > As for vp->dirty_tx, the WRITE operation in CPU0 is performed > with holding a spinlock, but the READ operation in CPU1 is performed > without holding this spinlock, so there may exist a data race. basically the same thing as race0 > ****** Possible race2 ****** > CPU0: > vortex_boomerang_interrupt > line 2510: spin_lock_irqsave() > _boomerang_interrupt > line 2381: vp->handling_irq = 1 [WRITE] > line 2498: vp->handling_irq = 0 [WRITE] > > CPU1: > boomerang_start_xmit > line 2134: vp->handling_irq [READ] > > As for vp->handling_irq, the WRITE operations in CPU0 are performed > with holding a spinlock, but the READ operation in CPU1 is performed > without holding this spinlock, so there may exist data races. It might but it is not serious. As the comment explains, if CPU1 would miss to then it would spin the lock while CPU0 would deadlock. However, I doubt that this happens because the core should hold the queue lock. > ****** Possible race3 ****** > CPU0: > vortex_boomerang_interrupt > line 2510: spin_lock_irqsave() > _boomerang_interrupt > boomerang_rx > line 2669: skb->ip_summed = ... [WRITE] > > CPU1: > boomerang_start_xmit > line 2149: skb->ip_summed [READ] > > As for skb->ip_summed, the WRITE operation in CPU0 is performed > with holding a spinlock, but the READ operation in CPU1 is performed > without holding this spinlock, so there may exist data races. This race would exist if the skb would be simultaneously on RX and TX side. Otherwise we good. > > These possible races are detected by a runtime testing. Could you please define runtime testing? Did something happen or did you just instrument the code and assumed that it might happen?cG > A possible fix of these races is protecting the code in > boomerang_start_xmit() > using the spinlock in vortex_boomerang_interrupt(). > But I am not sure whether this fix is correct, so I only report these races. Okay. As explained above, I don't think the races are real. > Best wishes, > Jia-Ju Bai Sebastian