Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1615460pxp; Thu, 17 Mar 2022 12:47:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaHtlSbmDN5MvA492lwPibZyZVXIv5YYB9h9QFW7+4eFP4Sp9x/uJiofbinMPiOCVfzDU4 X-Received: by 2002:a17:90b:3e88:b0:1bf:3a96:54c1 with SMTP id rj8-20020a17090b3e8800b001bf3a9654c1mr7249462pjb.244.1647546431832; Thu, 17 Mar 2022 12:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647546431; cv=none; d=google.com; s=arc-20160816; b=XYT6V9FpTLAIAdN44M6LBA2iRH7cMK5pkuOooa4+7JvA+lOY3KHhCdpW4OlgUjZ2iJ 1PUc4cpCrnSGJUxqHlGHc54s+pUhUeILDCCYfYKXynpSInaw9aASko59fh0LqbFGaMyN PV+1Fs26WEleLtBY1ol5n2TxMgP6W0DXt1xol7IGgdNaK+k8KTShd5opCY5bRkWbQMS1 VByDM96oEZekRuPbYAz8bFIHelmr9FM+r1+GImMZtJv4ZQy9sS/ZGpivVPXFeovGUSAm +x2fJQhJXc2Gdc0GmMnjm97CEmJG05QlV1fcruvJppaqgk210ex20P30OY+Nd+HA3tPR vtSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MHU7HL1YbkYl1iGw48u7RYBX95wOhuSGQ0pOCkTFad4=; b=hzxtbUcb0IhlzibD68yON0XsvyUJWqmoEH5ReqMH2Rtxmx6sg6kQr5aFLOQcnBIUSD MJoMBbF5qNQRapxGr/ztukO+n21ndXqvdMPMiAj2ykS226Brh4OvNv8hkGpsEpL8hjx1 ViePbsk3I3NJLU9JODZOfWNiWCSU2N9bL/mGcO8sIuKPfetWNiBVvanWL30WHilwHfYc qNnOW0oi+o1k8uYLYVnZLV/R2dZae/A8eYwyNz3kxcHIhuxump/k1pj2Ml1NkjW3GIv6 k8ak7fOZNORGEuUkulW7GQULYRB0fUFBdUwdEz+lg5/I9kzefhDWPiLSYukle4D16jxg 9Gww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=scfxrp89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e2-20020a631e02000000b003816043ef18si3008124pge.269.2022.03.17.12.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 12:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=scfxrp89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E4C9F23F9CA; Thu, 17 Mar 2022 12:45:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230383AbiCQMvc (ORCPT + 99 others); Thu, 17 Mar 2022 08:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234025AbiCQMu6 (ORCPT ); Thu, 17 Mar 2022 08:50:58 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFE81F163F; Thu, 17 Mar 2022 05:49:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 0B429CE2343; Thu, 17 Mar 2022 12:49:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF0BDC340E9; Thu, 17 Mar 2022 12:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647521338; bh=bQKb/8DrWNMbBis+IalTjpk+vmrHXhZPKgQ8CXaTJww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=scfxrp89+l5CodvXQ6m+cak4xuwpqAzexYKmE0dnIgrF1TDaplPi8sc3GnRq32a+i kXTpp8R+oORoNtUV0w0jy5oJErSvmpbc/bJbmlOQ0sjzGpFyQTk6z74ptiiOnCBkiE vftT90NMdBrPct1fS13iBZJJX+MaZwUU//86yNcE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niels Dossche , Martin Habets , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 41/43] sfc: extend the locking on mcdi->seqno Date: Thu, 17 Mar 2022 13:45:52 +0100 Message-Id: <20220317124528.809707535@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220317124527.672236844@linuxfoundation.org> References: <20220317124527.672236844@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niels Dossche [ Upstream commit f1fb205efb0ccca55626fd4ef38570dd16b44719 ] seqno could be read as a stale value outside of the lock. The lock is already acquired to protect the modification of seqno against a possible race condition. Place the reading of this value also inside this locking to protect it against a possible race condition. Signed-off-by: Niels Dossche Acked-by: Martin Habets Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/sfc/mcdi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index 2713300343c7..ec551def5835 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -163,9 +163,9 @@ static void efx_mcdi_send_request(struct efx_nic *efx, unsigned cmd, /* Serialise with efx_mcdi_ev_cpl() and efx_mcdi_ev_death() */ spin_lock_bh(&mcdi->iface_lock); ++mcdi->seqno; + seqno = mcdi->seqno & SEQ_MASK; spin_unlock_bh(&mcdi->iface_lock); - seqno = mcdi->seqno & SEQ_MASK; xflags = 0; if (mcdi->mode == MCDI_MODE_EVENTS) xflags |= MCDI_HEADER_XFLAGS_EVREQ; -- 2.34.1