Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1042068pxb; Fri, 1 Apr 2022 03:03:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZdI6bOLPIjbQB00Yr4S+y1+BDUNxtPHOo2XNUr/yfGlHrsBAceLEsn9ZJs8EcYXi6xpAZ X-Received: by 2002:a17:907:3e25:b0:6e1:40ec:29d7 with SMTP id hp37-20020a1709073e2500b006e140ec29d7mr8623396ejc.119.1648807405060; Fri, 01 Apr 2022 03:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648807405; cv=none; d=google.com; s=arc-20160816; b=UEVkalpIipPNzIb8Ah3u169UAIx8Sw2ja7PD9DMAHG+ap4jojhPCR1cgIPn5d7zE7w SVmeUr5Kfcx+j/vQtckBMTFZNeEh9qO5qldz8DpYJ6diiTt28507GVqieKmiE19Sria3 7ykRkayCGWFqSuBa5kFllgKP3XcCfeH033Hjuab8Tqrl4TwjgkXXk38JIA/3ovj94rO2 aQ5lIMziBkHj3VWs4CWGKR+dYHNeTedqOkUIRuvcRCfX6/mfrMwzfzc+IxH/JPTGD1yR jdbTgHA2UWFdEUabKaoiVnfn1FbSwMJxeRrBt6OMZHZFT5SFIR8mP1FqHdk7sL/P95+x x2uA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=v8/zU1sMY3yS+tcb1Sho2mb+pIX+PEBuc2KI2UecOM0=; b=LzB74BmuEhqGMpS3P4T57TZgf8qKZYYCVKBjS8Ttvmu5j2EQchVQsHJU4r5ukIUeKZ q7Id+wvDCLAT+XR4W1qXKTgInJ2De9iFZn73n9fqsF7DkezyQ1ZMabNlrB4bPnTWleD/ Ky038ygdHsxiu11S7RGT7IkZI/aoeU9NIlatZekqbdTwcYQuuE6OHGtQgkgmOC2CTRxI S+tqjxiOwt6fAJAfQ4QEOZYjp1HMqZcJgtj/Q0OrfyluQWrFp/lzLSi8p0o3f2ZEyY40 d/p9wUPkuazT7kOAe4XBPL+cwpgbTiyQONM1BoITP9bCGUGuUH4RQIg2bNGepZFSqTC2 EFCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e9Aj5I23; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020aa7d842000000b00418c2b5bf0fsi1302248eds.497.2022.04.01.03.02.59; Fri, 01 Apr 2022 03:03:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e9Aj5I23; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234737AbiCaKv6 (ORCPT + 99 others); Thu, 31 Mar 2022 06:51:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232246AbiCaKv5 (ORCPT ); Thu, 31 Mar 2022 06:51:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B2E2E1BA69D for ; Thu, 31 Mar 2022 03:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648723809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=v8/zU1sMY3yS+tcb1Sho2mb+pIX+PEBuc2KI2UecOM0=; b=e9Aj5I2395m49MfYxr8QseyMxawdXaAYggthXuJd8hhiWkOyHCAT+RF/TlBbDcncJLZs+9 WDKVvcTlVo/JXCjnLf494//JRw7c1pLNY4aiUDvebhUC8UNznKFtN6SyMgYaQWqU46pvlN fs4L4aJdWe/FZrgaUJYfpNsVHB5//f0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-390-dC_MAcA4MsujrC9QVAF6yw-1; Thu, 31 Mar 2022 06:50:08 -0400 X-MC-Unique: dC_MAcA4MsujrC9QVAF6yw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D67003C01D9D; Thu, 31 Mar 2022 10:50:07 +0000 (UTC) Received: from ceranb.redhat.com (unknown [10.40.192.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0D92140262B; Thu, 31 Mar 2022 10:50:05 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: poros@redhat.com, mschmidt@redhat.com, Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Brett Creeley , intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net] ice: Fix incorrect locking in ice_vc_process_vf_msg() Date: Thu, 31 Mar 2022 12:50:04 +0200 Message-Id: <20220331105005.2580771-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Usage of mutex_trylock() in ice_vc_process_vf_msg() is incorrect because message sent from VF is ignored and never processed. Use mutex_lock() instead to fix the issue. It is safe because this mutex is used to prevent races between VF related NDOs and handlers processing request messages from VF and these handlers are running in ice_service_task() context. Fixes: e6ba5273d4ed ("ice: Fix race conditions between virtchnl handling and VF ndo ops") Signed-off-by: Ivan Vecera --- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c index 3f1a63815bac..9bf5bb008128 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c @@ -3660,15 +3660,7 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event) return; } - /* VF is being configured in another context that triggers a VFR, so no - * need to process this message - */ - if (!mutex_trylock(&vf->cfg_lock)) { - dev_info(dev, "VF %u is being configured in another context that will trigger a VFR, so there is no need to handle this message\n", - vf->vf_id); - ice_put_vf(vf); - return; - } + mutex_lock(&vf->cfg_lock); switch (v_opcode) { case VIRTCHNL_OP_VERSION: -- 2.34.1