Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3327289rwa; Tue, 23 Aug 2022 02:56:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR4JyInYhemdCo6VGnUmNWUhEXs+rlPHsX9qtFu4B3IGVgAavAdk4QGAILaJm6Hu4giUy19A X-Received: by 2002:a17:907:7678:b0:730:e1ad:b128 with SMTP id kk24-20020a170907767800b00730e1adb128mr16406933ejc.67.1661248577615; Tue, 23 Aug 2022 02:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248577; cv=none; d=google.com; s=arc-20160816; b=Db/IR6n0qb81NqI0mpT6AKC7SngzXmOtcKULIKUfo6WRHKtfgzGtwHmxG2o1SVeFiy tCqtmZ1B4hxr3a9WKnVI6fmyiu0ZJhbriFH/xOiX8/ZNH+gB+qnQve+MF6AB/guHhKFA FbkjfxzXZoWBFtXHf79CkNd5WifP7My5R01GQpW7j86B9fHF8XzxYatzExxYJznfPLu5 8YEGnPPijGwldLLpJWPphcSvN3cj+jb70UpHfgN9Y3l/7lnqiEgJek8nqEtBORjo+2eo U9OlOZBrFZXEGotKuhW7jYZlw8qEIqKuRNqcj9kiTskx9BJJugXdcdmAiY+9kEhv8+oH Zx7g== 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=jf/K4pmMzVLblDopvPfes+8mlM5otUp9LW+UwD6Z8iU=; b=nqG9sVb+J2Lj9MtaaPWVO15KM6wlwKHYSMcLiJFuPLmDU0gaqNNOW8tMoF2OC/If7S rSq2DqVMsxYMB/wah9mk9aUi4DdIwl90dJdNyVME4vT1PwssTueIZoW52qZUvupBAo6x oXqfmr0BbNH8nFlMfu43lrPIChBBhxuDTrwAK0u1EC56tzz0hUeyhfnrVJkkZ5NASWyL Wk3MTfbfvm3sv5V8Ui5AMhVpOsTTtXqp0PJdEXQiGLmzWEg1dr5FB6WPrqK/maVu2SP8 SZH5KH79yAsEXXx5McSYD31IN9nap+xOu3RR/58Fq75uOPi8iEI/TZ6NShLFOVZruMUJ Q+TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OyWipnLE; 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 sc40-20020a1709078a2800b0073094a56feesi343924ejc.546.2022.08.23.02.55.51; Tue, 23 Aug 2022 02:56:17 -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=OyWipnLE; 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 S1351286AbiHWJhN (ORCPT + 99 others); Tue, 23 Aug 2022 05:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351464AbiHWJfi (ORCPT ); Tue, 23 Aug 2022 05:35:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D3C496FEB; Tue, 23 Aug 2022 01:39:45 -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 ams.source.kernel.org (Postfix) with ESMTPS id B00EBB81C69; Tue, 23 Aug 2022 08:39:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB841C433C1; Tue, 23 Aug 2022 08:39:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243983; bh=cCp7HDZu1TX9MiE28RgccNIpZL6o0PAcUvQZmt32Vb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OyWipnLEm9S5+oekBJZc4nqYxT3T6q4PfjJc23EviWyFzRyHSzbs8LbUVxtwCBtj7 2CCGp/hpMXpdvPZP9eXKxxQDrCs8TgLs4EMXFYWGrie93H4vePbjiZxk2ZlCfVpqaE 5yMTdDXp5OlkGWJmuoo9vU4fFAcbhZT6SrYu3eCg= 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.14 038/229] netfilter: nf_tables: fix null deref due to zeroed list head Date: Tue, 23 Aug 2022 10:23:19 +0200 Message-Id: <20220823080054.943513120@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 @@ -121,6 +121,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;