Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1088615ybt; Wed, 1 Jul 2020 18:36:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAm6bX6U7koBup4CvoiyUDNRBW8DnwQkIS7SlHFDgfpcART2L8ylpl2XA717dZHRy9KXS0 X-Received: by 2002:a17:906:31c8:: with SMTP id f8mr14052165ejf.269.1593653790190; Wed, 01 Jul 2020 18:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593653790; cv=none; d=google.com; s=arc-20160816; b=FGoigFhUSOX5baKRwEIBGM3bsbwtVE0OHVhQsnoINPPJvaW6vu5VRpwk+iGdlp6Kfa Wpk8t6bVpYz6pw3GYPx2dzxXXWEvXO9WY1mCv6VWDhDXBIlrmH9tq+7F3d4JEeu6i9IH hZMcGfcOtjj8oLHYwr22Q0C8WTiy+Uor5x8Mtck/7RFMug8akpyQtfZMutuP6S0oFfTS Y21HQhRRRyc8DDX+/qGU1QdsJWr8RzdkINN7eALhX5eF8lEnBt3/B9qiVwMe0n+2y9W8 L25CbjAGzcCxr6sWB4JNQWT7bO0wPeyF73TbgbFzSfxjj34hyqSOEkiYW1spn3x5TNa/ KXPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N96iJNzTxhtKpWrcCPTWlYNanAM7ok5BKMjCndCRYBc=; b=JoRlGu2m8hZ2bkIiDn+yiHsaV0UnAYFGUvLgblhVi7RxwLsicxxsWc/Naz/XFUHlet 4xClDQqhpSEv4jXqh3QGCPMRDqrDZrKrUmmUCWJh7V7cXL6OihvnrhNYsWk2fBV7HzVD 6B0a/AhoYMa3ElADGSg4PdpDp3Ze7U7SZ21QCa8FqPccUbgpapuaWwALeVMKx0F2rskn zBMCXihnMP97vWq/JDuBppn0e/c0FfD02ZW699c2cMt415zcLNUEthmIACehArd1Zpi3 iVFNh7fqlV1UhEtFYkOkl7px8IXbbPeFQ6ruqYulcoJBQhJqCOSeAUul+tJmaYjHxTVE G+6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PQZV06qb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt4si5696678ejc.34.2020.07.01.18.36.07; Wed, 01 Jul 2020 18:36:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PQZV06qb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729377AbgGBBfY (ORCPT + 99 others); Wed, 1 Jul 2020 21:35:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:54030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728357AbgGBBX3 (ORCPT ); Wed, 1 Jul 2020 21:23:29 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA9922083E; Thu, 2 Jul 2020 01:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593653008; bh=V6Pmu3m83SA+fn0VRBHhHKrR+JTh1Ner59R44FVUyEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PQZV06qbtg6MkAq5TEi69YA1NQYfj12bpoY9rl+kCIWPTm7CccVd6oV8pe7y3zmHN qN0CTIduWwyKatekHCM7H64OEzcxpI48wswEmtwONcD93sDJdR3+F2j27G1F2fE9gw xqE530hk3lmCPLu1wkVv9vVqncpcHEAURJVesQFw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ciara Loftus , Andrew Bowers , Jeff Kirsher , Sasha Levin , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 27/53] ice: protect ring accesses with WRITE_ONCE Date: Wed, 1 Jul 2020 21:21:36 -0400 Message-Id: <20200702012202.2700645-27-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702012202.2700645-1-sashal@kernel.org> References: <20200702012202.2700645-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ciara Loftus [ Upstream commit b1d95cc2391ffac0c5b27256a4fb0d2cfb021a29 ] The READ_ONCE macro is used when reading rings prior to accessing the statistics pointer. The corresponding WRITE_ONCE usage when allocating and freeing the rings to ensure protected access was not in place. Introduce this. Signed-off-by: Ciara Loftus Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_lib.c | 8 ++++---- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index 2f256bf45efcf..6dd839b325259 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -1063,7 +1063,7 @@ static void ice_vsi_clear_rings(struct ice_vsi *vsi) for (i = 0; i < vsi->alloc_txq; i++) { if (vsi->tx_rings[i]) { kfree_rcu(vsi->tx_rings[i], rcu); - vsi->tx_rings[i] = NULL; + WRITE_ONCE(vsi->tx_rings[i], NULL); } } } @@ -1071,7 +1071,7 @@ static void ice_vsi_clear_rings(struct ice_vsi *vsi) for (i = 0; i < vsi->alloc_rxq; i++) { if (vsi->rx_rings[i]) { kfree_rcu(vsi->rx_rings[i], rcu); - vsi->rx_rings[i] = NULL; + WRITE_ONCE(vsi->rx_rings[i], NULL); } } } @@ -1104,7 +1104,7 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi) ring->vsi = vsi; ring->dev = dev; ring->count = vsi->num_tx_desc; - vsi->tx_rings[i] = ring; + WRITE_ONCE(vsi->tx_rings[i], ring); } /* Allocate Rx rings */ @@ -1123,7 +1123,7 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi) ring->netdev = vsi->netdev; ring->dev = dev; ring->count = vsi->num_rx_desc; - vsi->rx_rings[i] = ring; + WRITE_ONCE(vsi->rx_rings[i], ring); } return 0; diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 69e50331e08e9..7fd2ec63f128e 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -1701,7 +1701,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi) xdp_ring->netdev = NULL; xdp_ring->dev = dev; xdp_ring->count = vsi->num_tx_desc; - vsi->xdp_rings[i] = xdp_ring; + WRITE_ONCE(vsi->xdp_rings[i], xdp_ring); if (ice_setup_tx_ring(xdp_ring)) goto free_xdp_rings; ice_set_ring_xdp(xdp_ring); -- 2.25.1