Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2304844pxp; Mon, 21 Mar 2022 16:25:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpCgqfWtl1hyVOk9B7wCq0IHyw+mxyF1VwqiA2ouukW/lV2GuHi9mGizh/DIPVp9DpDFKl X-Received: by 2002:a17:902:b68c:b0:153:bd06:85ad with SMTP id c12-20020a170902b68c00b00153bd0685admr15174204pls.99.1647905123288; Mon, 21 Mar 2022 16:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647905123; cv=none; d=google.com; s=arc-20160816; b=K2IYnfRC/M8VWmTkexJpF/KHibNrDo8Hx9Uqgu/fYMojkyuBqSsVCNSu7Nbfi7rR26 bQbaqBeXJVfqWZpbExowKUlKJyHErHfUPpohqd/ZRBqx5SQL9WSbLfnqvAEiI2nwvaE2 siUdAmBKw5EXYxkeweH5UDsAC3qarEX9sdjjb2fYr9O7QtvwSSGeaAaSQawq9L/xfyt8 97wTaMTBhMyaOrG8S7lQX7Uwo8pBwcueWYReNT3rcvZK3LeDXfgX7/Uip089Ot8Zgj24 /DL9gGVN34pyRkFojgCg46yGZFb0Jwdqjl+heSrvo6IT2p+jjP1gtV4zQFgQ4Kxx1aG6 HDkA== 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=QpmX5M52rJc1yfCtkbK9K1Il1mow4yu1QV18BPaawLY=; b=adDCCdiEeUa/pYuWK/Jmcmc8zKOPmm9SYlgrR9JmcuYyrizLdXExoBTOxIZW6aHwko IAFvTZwAD4htsc+LqpZjo+v4zcdXU17MohUgi7PA+YVjVq7e35av5PCG2xb5AI/WggI7 H2pukmy1dNHj+j6fISKiqkkMHoMt/Gtl13/szCvrQ2oMYv8iOxyZIG30vdLGEORCWff9 Dq9PHFbUmMIvGG++hfwQbCyq9xOGD9BXJ8o/K0ETdIFBQQj5/fqQO3z76o6MAi6PCb1P wcmbFvK0RCIWfDi/QUS8zE9GXGlpdh5EYUnOw2rDYjaJ5gVz/N7cRN6aQd6mylw07ZSp ZQtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wPPv1QRq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id e15-20020a65678f000000b00383884f1eeesi721893pgr.269.2022.03.21.16.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:25:23 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wPPv1QRq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 78D893765DD; Mon, 21 Mar 2022 15:15:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349995AbiCUOJO (ORCPT + 99 others); Mon, 21 Mar 2022 10:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349003AbiCUODO (ORCPT ); Mon, 21 Mar 2022 10:03:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA6D1760CA; Mon, 21 Mar 2022 07:00:10 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 47EBE611CF; Mon, 21 Mar 2022 14:00:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5635AC340E8; Mon, 21 Mar 2022 14:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871209; bh=HNI1dha5r5/aV4+8R/lLlKF+uCGDZHZnncogH9gUa+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wPPv1QRqufrtvt5zZvYeg/Jr8thbcbgn72VnjEnC83hFYf6zZJbIADzjGXqmSkK20 VCxOGAGqVvywhDAP6yN0cRodKJHI3btroVztgdkHZAyspEu4o2MhtE+qUJ8ndX/ONJ 72eozrnFfFg2ZEPcNlVQED7xpIZGSOrpbaOfUn9k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Przemyslaw Patynowski , Dan Carpenter , Mateusz Palczewski , Konrad Jankowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.15 13/32] iavf: Fix double free in iavf_reset_task Date: Mon, 21 Mar 2022 14:52:49 +0100 Message-Id: <20220321133220.947912427@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133220.559554263@linuxfoundation.org> References: <20220321133220.559554263@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: Przemyslaw Patynowski [ Upstream commit 16b2dd8cdf6f4e0597c34899de74b4d012b78188 ] Fix double free possibility in iavf_disable_vf, as crit_lock is freed in caller, iavf_reset_task. Add kernel-doc for iavf_disable_vf. Remove mutex_unlock in iavf_disable_vf. Without this patch there is double free scenario, when calling iavf_reset_task. Fixes: e85ff9c631e1 ("iavf: Fix deadlock in iavf_reset_task") Signed-off-by: Przemyslaw Patynowski Suggested-by: Dan Carpenter Signed-off-by: Mateusz Palczewski Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/iavf/iavf_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c index 711e8c7f62de..7fca9dd8dcf6 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -2133,6 +2133,13 @@ static void iavf_watchdog_task(struct work_struct *work) queue_delayed_work(iavf_wq, &adapter->watchdog_task, HZ * 2); } +/** + * iavf_disable_vf - disable VF + * @adapter: board private structure + * + * Set communication failed flag and free all resources. + * NOTE: This function is expected to be called with crit_lock being held. + **/ static void iavf_disable_vf(struct iavf_adapter *adapter) { struct iavf_mac_filter *f, *ftmp; @@ -2187,7 +2194,6 @@ static void iavf_disable_vf(struct iavf_adapter *adapter) memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE); iavf_shutdown_adminq(&adapter->hw); adapter->netdev->flags &= ~IFF_UP; - mutex_unlock(&adapter->crit_lock); adapter->flags &= ~IAVF_FLAG_RESET_PENDING; iavf_change_state(adapter, __IAVF_DOWN); wake_up(&adapter->down_waitqueue); -- 2.34.1