Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2277456pxp; Mon, 21 Mar 2022 15:40:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbgLGUhCoa5YxdDQ2sqmvasauxpsSK8aFi3v0dwvU0zRmwshWovj0aPbYjbukeEyqjBPbb X-Received: by 2002:a17:902:8e82:b0:151:6f68:7088 with SMTP id bg2-20020a1709028e8200b001516f687088mr15567172plb.11.1647902439309; Mon, 21 Mar 2022 15:40:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647902439; cv=none; d=google.com; s=arc-20160816; b=d/XtV9t0FPS8HewHEQhIVxZ9BFW3zZHfIVSImHJ+sLuUrxUfnh/p5yGco2zkI+sZ1X 2kPkf6cOq8eyO+CXXKVnCsFV5A8iLdwhTCmrapDuNrRyE3swE+7n7pUoYbQyf7/W4Zib BpUDx7I5KMgz3ojkJxR4EVcD3R/m7UCfuAAS+xk+rkvVIKFcPE8WO/7uvCSFVdWGi7b9 rg72I9YkhTG4cjWbPxhn7o6k762oql7nXhiWkOgjOGtML3gCSC4Nwu/THkC5gUfYarc7 837bebiZwC1p25hh6nybvNyB05mqmUooap6Da2iMpWz3yVTsohWAWQXrkUsClA+a1yDp FLCQ== 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=5rsTCG4GnbyfMqx9HRoY6M58wYBhYie3LVrL2sMX+2c=; b=NW3ndSkOD8WoiI934aQinWaw9+KGKWQDGV1lP+yt3TwSXOLecUqGd+V7C44swwcTAy x9CqHtpRua/t+4oC3L5DMRj6eEyGGbOEErsiTz/cE+G2qapvlR3UrOksl2gjQUcJUSmo YoD+8A3xs4PuUAEoRJOQubqvQOtm5bWRKcGFxxfREwAk5UGBUekViDEEUaf2m7gX/4Ab vPkedWiz3TnqVs70RqsUun210PUjB8hRR+TG8VR6TTdT1M0or8ApFllJSZYddQS7I7Co Mt7YTC/I48eGfOsu7Lc8XQ4kLbmCAhdpqdTfO5uwZHA8whmoYCpw9Z4vd13P8tB81Ke6 gtnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=01oShIts; 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 j15-20020a62e90f000000b004fa3a8e001bsi8052716pfh.210.2022.03.21.15.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:40:39 -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=01oShIts; 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 2EC098149D; Mon, 21 Mar 2022 14:51:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345284AbiCUOAK (ORCPT + 99 others); Mon, 21 Mar 2022 10:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348465AbiCUN5L (ORCPT ); Mon, 21 Mar 2022 09:57:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05B31174BA1; Mon, 21 Mar 2022 06:55:15 -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 ams.source.kernel.org (Postfix) with ESMTPS id 4958CB816CC; Mon, 21 Mar 2022 13:55:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB58AC340E8; Mon, 21 Mar 2022 13:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647870913; bh=XKxEb4u9yF8670TRoc9orT5QTT3LlhhvaaE0wk54nhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=01oShItsAVfAr/4OI3wYlluZljKpPF1DSBrWUe0v1GRiRzLCOXBc4LqCqT/zRV/cs S19cxU+dQqcNOmLHFhty918QKDEfF0h7oK27m+tnueYEui3SwkSCO6rh8lV5iFR9y9 3Y/lfK2HTSsTIB0bGhHqnSB9tpi8S0/2RZGihLz8= 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 4.19 15/57] sfc: extend the locking on mcdi->seqno Date: Mon, 21 Mar 2022 14:51:56 +0100 Message-Id: <20220321133222.428160717@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133221.984120927@linuxfoundation.org> References: <20220321133221.984120927@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.1 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 dfad93fca0a6..0fa64b8b79bf 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -166,9 +166,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