Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2860888pxb; Mon, 4 Apr 2022 00:33:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysoaUgQtRvY2tuFdFfvXb+02H03NfGGkhjN9GWRJutlQgG72TtLoT1WsCp3wAOW5rEPnOs X-Received: by 2002:a05:6402:5111:b0:419:74a6:6dc0 with SMTP id m17-20020a056402511100b0041974a66dc0mr31872411edd.293.1649057586312; Mon, 04 Apr 2022 00:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649057586; cv=none; d=google.com; s=arc-20160816; b=qdY/wt6hMVr0knIH/3uYwvHlUK1xIsPhu19t73FYe5GMdm+Y4iI35mMZj+Pplmkktq p75YAnMG6bsDMZhG766MPn8/iwk+5HKyRIj1dLvJlB2/uuLwWXsPqmbJOsUHZxRACfMv 1hbUMwboEh0+ddqPku/JjDKWv8cHC86YsOVHDcJlw6iHAuKAxCnKR7DrH6QAiZNMi/sO MyHERiWzE86tF8mxAuV0uJmMnTqn87DQnEy07BZG4xGLH5c+xc/D2hM6ejgPIGE+jTFG XO5fFjvEvocWVAUkExk0nkQuaAaDk+0FiGLHumlVaJtDfhdIKri1dgJ8wJXemWhyy0zP b4XA== 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=37yAvQTIEV1IvNK0QI/IF+EVq5TLZBtgSkNUfD0vZVo=; b=uf+tscYT5CcKPamNO92Ys4YdlUl1MlfyNbYSHTdRDWe5F6x47xlkHjSGiMrbE+PA1n kX7zRlbmhSktJeOJTwme5NhOzKiC8ZlJtRFlGpp6jFy0JUAVT1TdnY45ZyfCHfYUgUwk V7YjX76V6uNo/0kQv/8IYFdngbP5Gq6XCbM8bKJbFPbayMGotNkIgZLexZOP/FGIHCu6 5HRen35oLTzTs5/PenDmFfZiZbtO0t4Sn/BIjvObZm0/k1fHj8QN0wpBgGSahMurl22C q4dBg9TqIdFVfnIejfNrLzkH3d4L1IuokwUUjf3bcICMMVnBYxr4Mnm2n5rgAqVyeOMR nv2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S2TTZGqe; 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 hh6-20020a170906a94600b006df76385b86si5731828ejb.38.2022.04.04.00.32.41; Mon, 04 Apr 2022 00:33:06 -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=S2TTZGqe; 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 S244221AbiDAIt2 (ORCPT + 99 others); Fri, 1 Apr 2022 04:49:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230512AbiDAIt1 (ORCPT ); Fri, 1 Apr 2022 04:49:27 -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 1EA6F3C72A for ; Fri, 1 Apr 2022 01:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648802857; 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=37yAvQTIEV1IvNK0QI/IF+EVq5TLZBtgSkNUfD0vZVo=; b=S2TTZGqeW2szXRCPL5VwjoG28KuX9qhhcvhqAmMbQXNbjoMnZvVqrIGFiLuFGag9qhpfo6 5WqW0SDUSJeqfUIk5+kuQ3AAImG5EYe84GMA8rdJ2jr0AlctCqc8wX2Uqsqmm2AI55D3Ti YSvDPCXi7dUtLbrt7txlNfgKgoQCkII= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-cqP0x8lDMBuv4wQq1Nu4iA-1; Fri, 01 Apr 2022 04:47:33 -0400 X-MC-Unique: cqP0x8lDMBuv4wQq1Nu4iA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9C36101A52C; Fri, 1 Apr 2022 08:47:32 +0000 (UTC) Received: from ceranb (unknown [10.40.192.123]) by smtp.corp.redhat.com (Postfix) with ESMTP id E73405E194A; Fri, 1 Apr 2022 08:47:30 +0000 (UTC) Date: Fri, 1 Apr 2022 10:47:30 +0200 From: Ivan Vecera To: "Keller, Jacob E" Cc: Brett Creeley , "Fijalkowski, Maciej" , "netdev@vger.kernel.org" , "moderated list:INTEL ETHERNET DRIVERS" , mschmidt , open list , poros , Jakub Kicinski , Paolo Abeni , "David S. Miller" Subject: Re: [Intel-wired-lan] [PATCH net] ice: Fix incorrect locking in ice_vc_process_vf_msg() Message-ID: <20220401104730.44cd443e@ceranb> In-Reply-To: References: <20220331105005.2580771-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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 On Thu, 31 Mar 2022 19:59:11 +0000 "Keller, Jacob E" wrote: > > -----Original Message----- > > From: Brett Creeley > > Sent: Thursday, March 31, 2022 9:33 AM > > To: Fijalkowski, Maciej > > Cc: ivecera ; netdev@vger.kernel.org; moderated > > list:INTEL ETHERNET DRIVERS ; mschmidt > > ; open list ; poros > > ; Jakub Kicinski ; Paolo Abeni > > ; David S. Miller ; Keller, Jacob E > > > > Subject: Re: [Intel-wired-lan] [PATCH net] ice: Fix incorrect locking in > > ice_vc_process_vf_msg() > > > > On Thu, Mar 31, 2022 at 6:17 AM Maciej Fijalkowski > > wrote: > > > > > > On Thu, Mar 31, 2022 at 03:14:32PM +0200, Maciej Fijalkowski wrote: > > > > On Thu, Mar 31, 2022 at 12:50:04PM +0200, Ivan Vecera wrote: > > > > > 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 > > > > > > > > We need to know what is *the* issue in the first place. > > > > Could you please provide more context what is being fixed to the readers > > > > that don't have an access to bugzilla? > > > > > > > > Specifically, what is the case that ignoring a particular message when > > > > mutex is already held is a broken behavior? > > > > > > Uh oh, let's > > > CC: Brett Creeley > > > > Thanks for responding, Brett! :) > > > My concern here is that we don't want to handle messages > > from the context of the "previous" VF configuration if that > > makes sense. > > > > Makes sense. Perhaps we need to do some sort of "clear the existing message queue" when we initiate a reset? I think this logic is already there... Function ice_reset_vf() (running under cfg_lock) sets default allowlist during reset (these are VIRTCHNL_OP_GET_VF_RESOURCES, VIRTCHNL_OP_VERSION, VIRTCHNL_OP_RESET_VF). Function ice_vc_process_vf_msg() currently processed message whether is allowed or not so any spurious messages there were sent by VF prior reset should be dropped already. > > > It might be best to grab the cfg_lock before doing any > > message/VF validating in ice_vc_process_vf_msg() to > > make sure all of the checks are done under the cfg_lock. > > > > Yes that seems like it should be done. Yes, the mutex should be placed prior ice_vc_is_opcode_allowed() call to serialize accesses to allowlist. Will send v2. Thanks, Ivan