Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2874188rwb; Mon, 15 Aug 2022 13:04:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR5AYh6N497wNjnlGUbfI5k1IRrgNU3VANIixsIrYvbcYlTvjsKwaUW8HZ5Fg/ibQMfgw+mS X-Received: by 2002:a17:90b:3807:b0:1f4:ecf7:5987 with SMTP id mq7-20020a17090b380700b001f4ecf75987mr19397020pjb.13.1660593891724; Mon, 15 Aug 2022 13:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660593891; cv=none; d=google.com; s=arc-20160816; b=nAFLm2Z5q5kUmdxZfb1X36QJ2DWVVuzMJ/oTsqXAD+491SDXJ7HWwG4JMNp1Q/h/aO hl5Vquey9rKt1b7NJfU8TKTcKqUTL2Sy5mMO0s7VScGEsIVKwkVkOiQ7mik89rmmUIsw Pc9Lx19bpsIcODB8FYk4ssfpMpUnPqczlikO4ceUzJuBfr72TDlp207y7tRdPidW+vl1 RArk3mETME2djo6XezlHbgVyZSQl8EXE1npO+h9VvzqGTriN7xHTrl1u7OAqxuMmltv/ dTJMGB0DBpaOSBS3MY4u6F0SleuJ9Ul9vZoNkcTKrnc2I9uavyNGBOFx4dIZI+duy8Wg 4vLQ== 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=vUbuC0Aus1s4RZcX88yLUaDZUVlipgA2KMaGSvXW/219vZYrv0UvXHa7i0f+j9L4l6 LX79dd6O8XcIYKOqtvUUA3o+4MbGv9F0GqX9Htbe7Fnqdy7wi4yzTJMuD5nLF3oGJ8Pz zCua7uy3iXiZkWgn8v9MK1g8OSBedXW07tQ6X2aPg2VrWHWVdbpdZ0vmArKR8uuvIUW7 fztCYhHRHVSkPG1uU1TP6ZEU0IHZAA1yGCXZmb5VFR5wTfMRvrNpXELpePdBpIaO2niG 85smCBbHBElA/uSr3UAzGDwXbDWMurGiPwxUEKQ3BbiCX3e5cJLs9E19dqefYwix4SNN qb7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=drS5MyEB; 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 h8-20020a635308000000b00415e477c57fsi11771304pgb.436.2022.08.15.13.04.40; Mon, 15 Aug 2022 13:04:51 -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=drS5MyEB; 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 S242350AbiHOS2g (ORCPT + 99 others); Mon, 15 Aug 2022 14:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242131AbiHOSZz (ORCPT ); Mon, 15 Aug 2022 14:25:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BAA02F664; Mon, 15 Aug 2022 11:19:01 -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 6F88F6068B; Mon, 15 Aug 2022 18:18:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64B27C433D6; Mon, 15 Aug 2022 18:18:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587517; bh=1nyJF6tS4IDL2t+3hw/6H7P10fs3MNbMX922x6MthPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=drS5MyEBryUcRSH9sKlDXT030OiwP4Bkmr1K2LAYqpHv1Xwl+0+jLDWol6B4ra+oi PeddlfWBeiplnwTEEjm5U0jaVLCbD2cyUUwBxqdpputZ7vGamuRgVy9jGoB/+UGrF5 zh7Oq436VeKu9C1QBXE5MyF2yCGinlWqAJyr9qjs= 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.15 109/779] netfilter: nf_tables: fix null deref due to zeroed list head Date: Mon, 15 Aug 2022 19:55:53 +0200 Message-Id: <20220815180341.982021377@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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;