Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2914681rwb; Mon, 15 Aug 2022 13:59:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR7EJ4CMpc61XKdAxXHLeXrZno56n+Y3t38HH4uPRMOFb65VdZedyxodjuFIZqZc71UJz1I/ X-Received: by 2002:a17:90b:20e:b0:1f5:26b0:f506 with SMTP id fy14-20020a17090b020e00b001f526b0f506mr20385578pjb.65.1660597149753; Mon, 15 Aug 2022 13:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597149; cv=none; d=google.com; s=arc-20160816; b=voGtuuuyigGTp7pdjvhjwoUxtJ0p3dfTqU3YN2M+5xNPzXrH3uL2pMM8jo60GHoxFn Ntvn4EAFBTfQTalMRcD6IruUAc7WyuVnw/ugbbZtALKjcyugNgZ+GJF2n7IzfS/Wjccl SvfNCGldrfwmKSh1rpcCRPvI8WG5EhVxVvOsHMSFLZsdLOFuWEJSaMIJFeCbLaJvp1up Yxa9IW9GYapzNrXxkJ/8eAubCW7L+/mZU6cFortsB8z1TgyDVUOJyAqp++g2+liUkOP+ PaENEfvGZGQYfKdACkXuErHxDXa0svtr0rrf0hluQZWRkT7yFN2ZohVd5BGAo7ZTyVBV WJPg== 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=NoJ9V8TJSx5Mnryi+lM3KqAiIcz24l5wrfi99+Wn5vE=; b=X9KoKlLQvSPsLEju2/NiJRp3DxgZL/GVxIJAz9P0ITL8Fh3e3p1rXvj4L1mIkKDtkQ 6iwp3OTGsjT0rkD6tXscygzjpPROqz0NhccJSFCfUL6P/XtgHwkjYyc2okbHl5A/mj23 snA4yOYYvGMSd8ObjO+nsk2nBrU50FRscZxS9YieOmSo7Z++Do2rjydXHbUPKKWooMjY Rx5EVgu2OJiSCLHG1q2BHvYRo35gNYqwDzXzj+xDo2hM++BELp/CoJXFzBNGovU7GGZ8 NH78nN0Nj5I4L7+zyRLu4nEHJz4e92EVP6xsCu/Iw8Ryh+PEf/IGwz+KiLt/E4Qd5OC2 3cuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0ePCxzTc; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r1-20020a639b01000000b0041b72fda9b5si11699164pgd.311.2022.08.15.13.58.58; Mon, 15 Aug 2022 13:59:09 -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=@linuxfoundation.org header.s=korg header.b=0ePCxzTc; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345504AbiHOUaA (ORCPT + 99 others); Mon, 15 Aug 2022 16:30:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347327AbiHOUWR (ORCPT ); Mon, 15 Aug 2022 16:22:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EAF733E05; Mon, 15 Aug 2022 12:02:25 -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 9D3B861211; Mon, 15 Aug 2022 19:02:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E049C433C1; Mon, 15 Aug 2022 19:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590144; bh=1nyJF6tS4IDL2t+3hw/6H7P10fs3MNbMX922x6MthPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0ePCxzTclGBXUds528oE8Xre1xnG9L6qc9MuKjSOji2FNHkblKChcd5kS//Kd7PnJ BuT4sSNbiwTRbeAxuPW+v6eCRDkQE/hiWMjMqChxD1G2OFHKxBFwgInUMJxGYSb8f2 2IIZIHQ8jJcaitk/upUfN8ElNi4nJ57oigZtQITM= 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.18 0133/1095] netfilter: nf_tables: fix null deref due to zeroed list head Date: Mon, 15 Aug 2022 19:52:12 +0200 Message-Id: <20220815180435.095772843@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 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 infrastructure 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 @@ -153,6 +153,7 @@ static struct nft_trans *nft_trans_alloc if (trans == NULL) return NULL; + INIT_LIST_HEAD(&trans->list); trans->msg_type = msg_type; trans->ctx = *ctx;