Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2351551pxb; Mon, 20 Sep 2021 19:47:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM7jZC3VDSDYaaRdplBS327Vw/OJlGmbqn076kCMSVlh8iuBHOvngwk3ALYreakU4JkNFe X-Received: by 2002:a92:cd07:: with SMTP id z7mr19537329iln.15.1632192462489; Mon, 20 Sep 2021 19:47:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192462; cv=none; d=google.com; s=arc-20160816; b=HIdnPX6QAZyWFEIUcbfHddR0GfgC3V8gqYbqfCgOULZtFkP4UD8LHjAUvbpNFTXdhT ogt5EzAa4coEIzlOQqq9tzSA3li7cxB55SB0NNoCP+ddnPyE8rRdjG0GgAfyw5iW3i+u OWzuuj6hmG5MNTHhud1tpFilc7DL2imJHCIS7LgHpDdZuwLlFNUXvKKHHUe9IxT4K2IN jSLXETksSWOeNSLW+pBhGkohDCCMhUCGDStgKqpmF1s0a6pYBmP7C1pT3VPnZ8c0/Qe1 Nx1QM4k30lQ9pLFIdfphmc8p+cQCqCp0/+J/Gv58hsLvf/1WiBm/pGx2NQkPOmTfKcH/ y1Gg== 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=vLhp0FU5jw+r1tEzLbcmzjCTOy6INblo9HsieHoZpNE=; b=nt6VEOxpwny5UTnPHrViS7eCG0wHLvIAOJM0F7joEb3L1F0E1W5MsuHuj0vEJXd4ye AfUNgboL8t2XILBCzKf+N/d+ReCmWBhPL65tl1I4NRkcG660nsY9uKSWO+ZL4YJcQHu0 qn9bpH3B2rMm/PljH7pd0vVBgQAP+sOXCHtdZwepWo8RrtGI8TYD5gwz8oPcmSRGjNjb +5LeJt7PqB8GppLG8pffP3Xs01wtmRTrBH2CTTOQoqpYldAEggFsylSKEhzRzZAhTE7r InHeNx6dvlvvqn72HdrnyRjhplZ3pETyqMNQOUrvRDlSM9zXAfKbdJeqnwbWmB1aRiLF Z2NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JI475UBB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si12978497jat.15.2021.09.20.19.47.31; Mon, 20 Sep 2021 19:47:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JI475UBB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353229AbhITSd1 (ORCPT + 99 others); Mon, 20 Sep 2021 14:33:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:47600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378762AbhITS0W (ORCPT ); Mon, 20 Sep 2021 14:26:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D174632D5; Mon, 20 Sep 2021 17:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158736; bh=k7E797n/Y2cFvxCBGF4ElxjrT5r0KptUAHTxFF/lXwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JI475UBBjchOZF+ZPU+yP2bDYPbU1lhpFb/4cjYeYXPnetwij1uKxRsWTcGUANKXp DGfB8M9r4NXE8l2ORCVNmxFyuDVcHSfHQZFVsQtl8x9+N1F1XG1a25EH1yDeBEfUOq 2ioXHbZBml2KJ9hmlZU9PPXXhrMEHrPFKkDgPeMU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Maor Gottlieb , Saeed Mahameed Subject: [PATCH 5.10 033/122] net/mlx5: Fix potential sleeping in atomic context Date: Mon, 20 Sep 2021 18:43:25 +0200 Message-Id: <20210920163916.883146660@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163915.757887582@linuxfoundation.org> References: <20210920163915.757887582@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maor Gottlieb commit ee27e330a953595903979ffdb84926843595a9fe upstream. Fixes the below flow of sleeping in atomic context by releasing the RCU lock before calling to free_match_list. build_match_list() <- disables preempt -> free_match_list() -> tree_put_node() -> down_write_ref_node() <- take write lock Fixes: 693c6883bbc4 ("net/mlx5: Add hash table for flow groups in flow table") Reported-by: Dan Carpenter Signed-off-by: Maor Gottlieb Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c @@ -1675,14 +1675,13 @@ static int build_match_list(struct match curr_match = kmalloc(sizeof(*curr_match), GFP_ATOMIC); if (!curr_match) { + rcu_read_unlock(); free_match_list(match_head, ft_locked); - err = -ENOMEM; - goto out; + return -ENOMEM; } curr_match->g = g; list_add_tail(&curr_match->list, &match_head->list); } -out: rcu_read_unlock(); return err; }