Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3408706rwa; Tue, 23 Aug 2022 04:24:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR63o29NrGjsNzR4JNEvfGFcO1MlPs8XcZIArXbG5QmVUyAr7FQeoqfwZjQnx1v+wtnFflEm X-Received: by 2002:a17:902:b206:b0:173:c58:dc74 with SMTP id t6-20020a170902b20600b001730c58dc74mr486996plr.65.1661253873249; Tue, 23 Aug 2022 04:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253873; cv=none; d=google.com; s=arc-20160816; b=LXi5vJC8nwTPW1MeHTs966+0SYDq1S+kQBPU3MUBD2/kfMWS8LkQ0UdhWE4F8+2aK1 XE7DjFpH5a+iS1yP0HrTlcSIPd9hloop42T/8eoFDjzQ8o9t0aLiUIWgVEEY2JUIzSWJ ZQLVGi9OelmR6HkT/2tx/0NB3a19OIQBU7142sj/KGR5jRGS3HN676gDIMCzWK5Vkp0F 1yOFIfWy+Spek7t9wHEh9/6zptea7yq0Zcqi/Sytuy8+rDe9RTq4CpmOXYWSy1BNfvCL YbQZMQQo2HHHf2IbYYHaBYuNQ1C2B8qDHjtvrOntkrssYi8MmO2p8U2+DqC0iX5T5FAo mJPA== 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=Zy+ksTJzRCtqKUZ3zx6Hgl6uN2jPmYPAglfckrOMoQc=; b=v2aiZpF8u98luj3q1r/ErAQohIdGU739Xi5IkBE1A3Qf6pVd1QwbD02/xmC7+F95n8 hhGtj+bHlqTpMRfn1NXKkTsWfDVvIGnu+TCvjaIHi1hqxP03YaNpMivwLSIVExINalpP h3CKncwCcO7x2cLHxH3ZdEJe5elPkWXMj4PT3Y6ePzksmf18wUTZvVt4/DvUOmzKQl2B gcZFAQKVXsd4iDSYV1+dDRBsIScby7FkFxiXxNCPEs+T+TsdS1s6AfGAn4cN8iTKIdOe bi4xeogc7kN58+f73991zJkh58RkO9jV8EelWjGlmxXTxiJnoE6yIVIoXHkZnd1ZnWZZ julg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AFhM64tC; 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 z13-20020a17090a1fcd00b001f7b6192be1si12362194pjz.25.2022.08.23.04.24.22; Tue, 23 Aug 2022 04:24:33 -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=AFhM64tC; 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 S1355355AbiHWKik (ORCPT + 99 others); Tue, 23 Aug 2022 06:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354662AbiHWKV5 (ORCPT ); Tue, 23 Aug 2022 06:21:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746CE2DD9; Tue, 23 Aug 2022 02:03:21 -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 48B6C61583; Tue, 23 Aug 2022 09:03:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5141AC433D6; Tue, 23 Aug 2022 09:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245395; bh=MUH9X5yO4wlFgKXfGRQ1GEK6wDBvOiKQnzrSbVhHJvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AFhM64tCh4oRWcZx6agDIE+e0zxGlHojlnCZATI3FtkevpjzvoYMzGqdCiRjft6wZ FCl2ssQsL9lYkr+GBh5dnveOg8RH91GjszL4qIeR0N7CmQ1WCsDmqxHG0uNhVNiATj 3ByOD0L/93jd+m7bAkSe+a5BLss9JIF/Ezz4KwyQ= 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 4.19 038/287] netfilter: nf_tables: fix null deref due to zeroed list head Date: Tue, 23 Aug 2022 10:23:27 +0200 Message-Id: <20220823080101.550008403@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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 @@ -96,6 +96,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;