From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C9DBBA4F for ; Tue, 7 Mar 2023 19:03:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE25AC433EF; Tue, 7 Mar 2023 19:03:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678215834; bh=F4sr+/Q7epTKblbrwwmwxWDfoq5dmcdAbtzRofTRupI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jfVhXY50DRm74T8p1M5eUUdg3V2Lu0mWActyjFElbzLvn0sAXuG1eH6EEj6KPi9oV RCvGzMqUr5fvEubA/epCqIoTrHrD7toPDFhSreXLAog61NIRPkJwZ1UA69SWWc2Rc6 J6pw3ZrglwA0t20LkRiAd9lpbM1qns4EuHU3AUIM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alok Tiwari , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.15 389/567] netfilter: nf_tables: NULL pointer dereference in nf_tables_updobj() Date: Tue, 7 Mar 2023 18:02:05 +0100 Message-Id: <20230307165922.694947133@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307165905.838066027@linuxfoundation.org> References: <20230307165905.838066027@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Alok Tiwari [ Upstream commit dac7f50a45216d652887fb92d6cd3b7ca7f006ea ] static analyzer detect null pointer dereference case for 'type' function __nft_obj_type_get() can return NULL value which require to handle if type is NULL pointer return -ENOENT. This is a theoretical issue, since an existing object has a type, but better add this failsafe check. Signed-off-by: Alok Tiwari Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 81bd13b3d8fd4..a02a25b7eae6d 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -6794,6 +6794,9 @@ static int nf_tables_newobj(struct sk_buff *skb, const struct nfnl_info *info, return -EOPNOTSUPP; type = __nft_obj_type_get(objtype); + if (WARN_ON_ONCE(!type)) + return -ENOENT; + nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla); return nf_tables_updobj(&ctx, type, nla[NFTA_OBJ_DATA], obj); -- 2.39.2