From nobody Fri Sep 5 20:23:14 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B968C32774 for ; Tue, 23 Aug 2022 11:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357266AbiHWLN4 (ORCPT ); Tue, 23 Aug 2022 07:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347074AbiHWLNF (ORCPT ); Tue, 23 Aug 2022 07:13:05 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B29DB941E; Tue, 23 Aug 2022 02:17:58 -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 sin.source.kernel.org (Postfix) with ESMTPS id AF293CE1B55; Tue, 23 Aug 2022 09:17:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9628C433D6; Tue, 23 Aug 2022 09:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246254; bh=Sp/9EUuJILzRdg6nBJEcMJpl4b+6BEiUl7qd5kaShWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ztzfZ/bpeCYfYw4okD2FxgVnA59JRDuaIA8E7H49zYBDJNuA9kSQnh4OJy0mUWX2X XoCU6A7ziEPNU3RBRJ2m6MpJcpTJz53TXmRe13gf11PltLNg8alKAy9TnNSALJ91Eq ITXoFcM4BcdLlftBBXrcjAOJd0PMhpuE6F9MadJ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, mingi cho , Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 5.4 050/389] netfilter: nf_tables: fix null deref due to zeroed list head Date: Tue, 23 Aug 2022 10:22:08 +0200 Message-Id: <20220823080117.694305417@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Florian Westphal commit 580077855a40741cf511766129702d97ff02f4d9 upstream. In nf_tables_updtable, if nf_tables_table_enable returns an error, nft_trans_destroy is called to free the transaction object. nft_trans_destroy() calls list_del(), but the transaction was never placed on a list -- the list head is all zeroes, this results in a null dereference: BUG: KASAN: null-ptr-deref in nft_trans_destroy+0x26/0x59 Call Trace: nft_trans_destroy+0x26/0x59 nf_tables_newtable+0x4bc/0x9bc [..] Its sane to assume that nft_trans_destroy() can be called on the transaction object returned by nft_trans_alloc(), so make sure the list head is initialised. Fixes: 55dd6f93076b ("netfilter: nf_tables: use new transaction infrastruct= ure to handle table") Reported-by: mingi cho Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -113,6 +113,7 @@ static struct nft_trans *nft_trans_alloc if (trans =3D=3D NULL) return NULL; =20 + INIT_LIST_HEAD(&trans->list); trans->msg_type =3D msg_type; trans->ctx =3D *ctx;