Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3077188rwb; Mon, 15 Aug 2022 17:33:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR789fcDUgHfS6pzbGbTLuy7vkFYMyssY7OPn3hOP3Ti3NfbXKZjjHhPiR8niVKwU0ySrY/z X-Received: by 2002:a05:6402:3506:b0:43e:954b:bc8a with SMTP id b6-20020a056402350600b0043e954bbc8amr16936449edd.266.1660610020199; Mon, 15 Aug 2022 17:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610020; cv=none; d=google.com; s=arc-20160816; b=haUCrv1eoTa4vtwv/L8C7js7YoH3futkX931Wb1mavsq2ZLxCbZ3LB+XsctCu/yHcB OmXchXRdXy9foB9dAwpTVjbwS9k0ddiIWP6ZZxu71jypicrbh8hGILuK0h07xpB7J3XS DD5y8thdDZM4VZt3aq0gYtUznx3Tjg/F+lLg1/F2R9GnFSDEuMowrzZAb6eVzjBMGd8/ 7sU6lKX/z4lNUgjymnhQx99/fQrcYpGQUWLQUQ58Q6IckbYeM20XHP4uDdAJDkVSReYO iqsmRw1jDxE57Ovjq+s9ArMKK5gHVcMsEFQU8e8f3oj3bbbPp2zFvU3RHsi/4AsxP1qF z7xQ== 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=J075sw9/CqE0j9HhDNs2FNBZSEm7Akk7CDC1ijKGf7d/9fjJHUtHfT5IzHFOVS5C8O ydwH/1PhUz74zcBQV6XTne4YTY/u0o0TqxI4RDrliLDbeA6+U12gSFkr3n+uzk15B4Je h2Ny02L35dCvGZSOl1u7bvhmo1l9jTVAoIpU3mjY2q0451PfNurtb+lHeFY/7odIeEMF qPHb+CHFWNEWBWQSJKuig4cQBsEaccezrg3xh5r4Dk39QFca6KFhfXH0JUsIVaU+p/+d eehzo5NfLlQVV8AKCMafE+GXQ+FJEDwrGEaIwjt3hlC+eQNWqEbV1dRGwR/wJ3tc3V6H QRyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jwvMdp5V; 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 he33-20020a1709073da100b0072f0a99a61asi9576075ejc.617.2022.08.15.17.33.14; Mon, 15 Aug 2022 17:33:40 -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=jwvMdp5V; 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 S1343584AbiHOWa0 (ORCPT + 99 others); Mon, 15 Aug 2022 18:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348520AbiHOWZi (ORCPT ); Mon, 15 Aug 2022 18:25:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D86D126949; Mon, 15 Aug 2022 12:44:29 -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 36347610A3; Mon, 15 Aug 2022 19:44:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 245C9C433D6; Mon, 15 Aug 2022 19:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592667; bh=1nyJF6tS4IDL2t+3hw/6H7P10fs3MNbMX922x6MthPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jwvMdp5VrbFhjLEm8zCN+kV53u29vXJjgSXyn22weB6sx7zW5AG2YM3VnJm2eO/jc Cy1IxaO0I1aHan/6LiemPSy8AeGv34X6BR8WA53Zvgc7r5Ex/Qph0WsNxYVCKRrRiw S8ohYDJxnFAdVVrpY896ZTd9T8MXuQCqWM60gsuM= 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.19 0145/1157] netfilter: nf_tables: fix null deref due to zeroed list head Date: Mon, 15 Aug 2022 19:51:41 +0200 Message-Id: <20220815180445.432580001@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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;