Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2385667pxb; Sun, 17 Apr 2022 21:10:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpkGiPU+BG3clQjxCu7uRgUcvtRB0p1OdVdsbOMK9Sr4bFdAflq9f+i6QPS488hMIm54TX X-Received: by 2002:a17:90b:3a90:b0:1d2:80bf:d968 with SMTP id om16-20020a17090b3a9000b001d280bfd968mr6299621pjb.16.1650255028214; Sun, 17 Apr 2022 21:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650255028; cv=none; d=google.com; s=arc-20160816; b=EgSOQ4fNzpXnrFznh5A/BqlScjKnU8W77179K21t0r4qIrJlzIPUY8LEpPRyyJuzl8 rnghXCmljLfYenCAkaQbyTTZd1D5iT2YaauNyfhQTOjaQFnw+Veg/fqIi62SNe5s8REO 2xT810RddhCacXpa+iDARDEgu+Sr2gPzZZqvACDynOZlWWJarNnt80gddQyIXVMrtWZn /wUWGwneXUapdPqXBUjWNYwLJ9yD0f1fapTsxGCNqSPFpI0yS2XxnUbVj2RDyFQnSFUq hb7Xb1qY8UmjtjbVP4b2HPDO40tdk6/2g7Kbac4WeoMyJEcO2I+uvCYmNSQbj6GH+FX+ KfIQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=bAG/WM0W5/enoG6FatM/xF/Cjod8FMGsP2hun8D0RyY=; b=knlnFpEq0n8goZnGM9+ExtsSdk4kApzSuAIpVUEifmNcZZtl4e9KuWHqFJ7qgAcOC8 k6a+aLzstOCJLTPChDa5k9WZpUz8cAWw9vCDuTg3xVc8wUvQjGziESGK5cr7RY18BhpJ OVH/IaOc/Rsi7rg7pdpQXHE14S8N+aelsw0jpjr8uEPOXmdGDJkEUmnlbLxc2vW2r05s fjvM5NldEz5gKrZJkajJ2tSGPqBWCYRCr3eVq/A2skmB2dHCYhmsWpOMe6te0olqDrZm YYw8q2hyMdz4Si//ogKVJePXHqAQr50dRobQ5NFiEtZ7C8FCLZ/5VvhuISRS6g7en6Q5 ohfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LhP8sQc4; 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 m12-20020a170902bb8c00b001567e872208si8217117pls.217.2022.04.17.21.10.12; Sun, 17 Apr 2022 21:10:28 -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=LhP8sQc4; 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 S231776AbiDPLdZ (ORCPT + 99 others); Sat, 16 Apr 2022 07:33:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbiDPLdY (ORCPT ); Sat, 16 Apr 2022 07:33:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AB8AD40A21 for ; Sat, 16 Apr 2022 04:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650108651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bAG/WM0W5/enoG6FatM/xF/Cjod8FMGsP2hun8D0RyY=; b=LhP8sQc4DRTyExLXhrgUjkHnsQc47tcn1xCsspdtHwvogGfZs7vBp7eX0bI2CvPNsGeaIr 070i9AqwnXy6gXy/LJS3zdcyGEik1heMfe4y60PJChdpjRUtIAttV15ZcMQNz3bNfKquCE JQ8Sc5GDRnUOP2jUnvaMvWJwZOzfJbA= 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-567-eaKJ0ggBPE2VTwyeBIMTyA-1; Sat, 16 Apr 2022 07:30:46 -0400 X-MC-Unique: eaKJ0ggBPE2VTwyeBIMTyA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 169A41C05ABC; Sat, 16 Apr 2022 11:30:46 +0000 (UTC) Received: from ceranb (unknown [10.40.194.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 424AE40EC002; Sat, 16 Apr 2022 11:30:44 +0000 (UTC) Date: Sat, 16 Apr 2022 13:30:43 +0200 From: Ivan Vecera To: Tony Nguyen Cc: Maciej Fijalkowski , Fei Liu , , , Brett Creeley , open list , "moderated list:INTEL ETHERNET DRIVERS" , Jakub Kicinski , "Paolo Abeni" , "David S. Miller" Subject: Re: [Intel-wired-lan] [PATCH net] ice: Protect vf_state check by cfg_lock in ice_vc_process_vf_msg() Message-ID: <20220416133043.08b4ee74@ceranb> In-Reply-To: <248da3d7-cb00-14b6-12f0-6bb9fda6d532@intel.com> References: <20220413072259.3189386-1-ivecera@redhat.com> <248da3d7-cb00-14b6-12f0-6bb9fda6d532@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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_H4,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 On Fri, 15 Apr 2022 13:55:06 -0700 Tony Nguyen wrote: > >>> diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c > >>> index 5612c032f15a..553287a75b50 100644 > >>> --- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c > >>> +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c > >>> @@ -3625,44 +3625,39 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event) > >>> return; > >>> } > >>> > >>> + mutex_lock(&vf->cfg_lock); > >>> + > >>> /* Check if VF is disabled. */ > >>> if (test_bit(ICE_VF_STATE_DIS, vf->vf_states)) { > >>> err = -EPERM; > >>> - goto error_handler; > >>> - } > >>> - > >>> - ops = vf->virtchnl_ops; > >>> - > >>> - /* Perform basic checks on the msg */ > >>> - err = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg, msglen); > >>> - if (err) { > >>> - if (err == VIRTCHNL_STATUS_ERR_PARAM) > >>> - err = -EPERM; > >>> - else > >>> - err = -EINVAL; > >>> + } else { > >>> + /* Perform basic checks on the msg */ > >>> + err = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg, > >>> + msglen); > >>> + if (err) { > >>> + if (err == VIRTCHNL_STATUS_ERR_PARAM) > >>> + err = -EPERM; > >>> + else > >>> + err = -EINVAL; > >>> + } > >> The chunk above feels a bit like unnecessary churn, no? > >> Couldn't this patch be simply focused only on extending critical section? > > Agree, this doesn't seem related to the fix. > > Thanks, > > Tony Yes, it is not directly related but it's just a conversion of following snippet to avoid ugly and unnecessary 'goto': if (A) { err = ... goto error_handler; } if (B) { err = ... ... } if (err) { ... } to if (A) { err = ... } else { if (B) { ... } } if (err) { ... } If you want to leave the code as is and remove this from the patch let me know and I will send v2. Thanks, Ivan