From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1917142624; Thu, 11 Apr 2024 10:44:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712832257; cv=none; b=IhAoJxyd+HVIh3tmfIJ8fAd3gOTOqraLuM1I+DMcHsZ5R3Et+Dc+1AkIdCdK8DCpGCtQTOXkcgP+d1OiogxKe2dPP2ULHq7Pxmftl26m6ysLZaWUCEsDyWxPJ/WulebSRPOCPXaT6zVHIJLckUAsNbxWlW54EsmCyG0uK2Wh40g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712832257; c=relaxed/simple; bh=WtIldR4tXrldgKOxVBQD8cLuqF/GC5/RiNe6jchsRmM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XkyD/U3+w084S0h4QNtIj1BByou5OaWHuyHNVxscsrehkr6kHCVYRgn88FVfl+aHnfSM0cbuLMEKBXDdNpsXx8ZK5p5MhDwxWSJ5RMunBqQ+aeiPz8MBRqrli+zML1rTXpeyhsMZw4lKGsYHVs4V3fVnyLFZpNY1v0Iey0xBK8o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zxOmrgIW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zxOmrgIW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC9FFC433C7; Thu, 11 Apr 2024 10:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712832257; bh=WtIldR4tXrldgKOxVBQD8cLuqF/GC5/RiNe6jchsRmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zxOmrgIWeXy1sYkNb481T7VMpcOVTojyFnKgooa+SilIeb2xY4c7hGXL8EqUBTTxl 0zLs0NuRVOyfsEq7tP2MYjBhT6BrUr8V5Z06CAraRoA6OAg4MXVs/2nvLraCzwbS/9 S/SrGEXVSKF6d3IrbdQBUnYHJQpPX1zwWN2HZgEw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuan-Ting Chen , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 283/294] netfilter: nf_tables: release mutex after nft_gc_seq_end from abort path Date: Thu, 11 Apr 2024 11:57:26 +0200 Message-ID: <20240411095444.056558485@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411095435.633465671@linuxfoundation.org> References: <20240411095435.633465671@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pablo Neira Ayuso commit 0d459e2ffb541841714839e8228b845458ed3b27 upstream. The commit mutex should not be released during the critical section between nft_gc_seq_begin() and nft_gc_seq_end(), otherwise, async GC worker could collect expired objects and get the released commit lock within the same GC sequence. nf_tables_module_autoload() temporarily releases the mutex to load module dependencies, then it goes back to replay the transaction again. Move it at the end of the abort phase after nft_gc_seq_end() is called. Cc: stable@vger.kernel.org Fixes: 720344340fb9 ("netfilter: nf_tables: GC transaction race with abort path") Reported-by: Kuan-Ting Chen Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_tables_api.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 6c5de620da9f1..ef271628975a9 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -8964,11 +8964,6 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action) nf_tables_abort_release(trans); } - if (action == NFNL_ABORT_AUTOLOAD) - nf_tables_module_autoload(net); - else - nf_tables_module_autoload_cleanup(net); - return err; } @@ -8985,6 +8980,14 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb, WARN_ON_ONCE(!list_empty(&nft_net->commit_list)); + /* module autoload needs to happen after GC sequence update because it + * temporarily releases and grabs mutex again. + */ + if (action == NFNL_ABORT_AUTOLOAD) + nf_tables_module_autoload(net); + else + nf_tables_module_autoload_cleanup(net); + mutex_unlock(&nft_net->commit_mutex); return ret; -- 2.43.0