Article View: linux.kernel.netdev
Article #16339[PATCH net 1/1] net/mlx5e: fix NULL pointer dereference in arfs_create_groups()
From: Jinvas
Date: Sat, 14 Nov 2026 14:43
Date: Sat, 14 Nov 2026 14:43
63 lines
10811 bytes
10811 bytes
arfs_create_groups() creates up to two flow groups in ft->g[], and
increments ft->num_groups for each group that was created successfully.
If creating the second group fails, the error path frees ft->g and sets
it to NULL, but leaves ft->num_groups at 1.
The only caller, arfs_create_table(), calls mlx5e_destroy_flow_table() on
the error path, which calls mlx5e_destroy_groups(). The latter walks
ft->g[] from ft->num_groups - 1 down to 0 and dereferences ft->g[0].
Since ft->g was freed and set to NULL, this is a NULL pointer
dereference, and the kernel oopses.
The same error path also leaks the flow group that was created
successfully before the failure, since ft->g is freed without the group
being destroyed.
Freeing ft->g here was added by commit 3c6d5189246f ("net/mlx5e: fix a
double-free in arfs_create_groups"). Before that commit, the group
failure path did not touch ft->g at all, so the caller destroyed the
flow groups that had been created and then freed the array. That
commit fixed a double free in the allocation failure path by freeing
ft->g here as well, and in doing so changed the group failure path
too.
Rather than also resetting ft->num_groups, leave the free of ft->g to
the caller: mlx5e_destroy_flow_table() frees ft->g exactly once, and
also destroys the flow groups that were created. This fixes the NULL
pointer dereference and the leak, while keeping the double free fixed.
This also makes the error handling of this function consistent with the
rest of the driver, e.g. mlx5e_create_l2_table().
Fixes: 3c6d5189246f ("net/mlx5e: fix a double-free in arfs_create_groups")
Signed-off-by: Jinvas <jinvas@126.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
index c5e62d7..7888d38 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
@@ -267,7 +267,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
in = kvzalloc(inlen, GFP_KERNEL);
if (!in) {
err = -ENOMEM;
- goto err_free_g;
+ goto err_free_in;
}
mc = MLX5_ADDR_OF(create_flow_group_in, in, match_criteria);
@@ -338,9 +338,6 @@ err_clean_group:
ft->g[ft->num_groups] = NULL;
err_free_in:
kvfree(in);
-err_free_g:
- kfree(ft->g);
- ft->g = NULL;
return err;
}
--
2.28.0.windows.1
Technical Details
Message-ID:
<20261114144325.816-2-jinvas@126.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363308-linux-kernel-netdev=dewy.ruReferences:
<20261114144325.816-1-jinvas@126.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363308-linux-kernel-netdev=dewy.ru From: jinvas@126.com (Jinvas) Newsgroups: linux.kernel.netdev Subject: [PATCH net 1/1] net/mlx5e: fix NULL pointer dereference in arfs_create_groups() Date: Sat, 14 Nov 2026 22:43:25 +0800 Organization: Usenet Network Message-ID: <20261114144325.816-2-jinvas@126.com> References: <20261114144325.816-1-jinvas@126.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1590344"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:0I0chZ5ZTLlyCxBXmmzR5BPvEh4= sha256:IxOSJ2MagdhJs7L6QsbLJMtDJj4SKBTcmz5bf5mmZEM= sha1:xGC+63yIiWXVOTmB1FYBsBk836U= sha256:pb42zr+7l1HmfoYfIQj0LbgKgy6raEGQNVsMeU+aKkk= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id C32F7114830; Sat, 14 Nov 2026 17:45:26 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.048 X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=126.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WW6m7dCiToum; Sat, 14 Nov 2026 17:45:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363308-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=126.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 9F01D1147D8; Sat, 14 Nov 2026 17:45:09 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 8A4673C7C0; Sat, 14 Nov 2026 14:45:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794667497; b=EfZBlIhDACw9vRAUsb9g/CV3QEfZLWHyr3vGEejJQG6jQAqzy/9ZgFlqKm5gP9AGBXR/ QR0ebU3kVGIAfjKnHRRobed/H5IkrWIfT9AcbZMFw8rF2vcfYdRxazeuaHROs3nbwA1VE 8OkA5x/w6hPzvBgGOkZgJSBkiAOE54YDNqshruqGCd7SbA3aniPLHIq+AQpp5e1r25bAV 97XftQCNQyHIAVyYZ+1FnWCBMCSi/TaEADqKbNLdkt47SIbrsHnDSBq+L3jsqhlkrrgPQ jDOQBsAWJpM4rFbm6HbsZnBdfe5IttWeKzXu4Jiiis+UFl6OnD7zIKVnU/A3tSqdV6Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794667497; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=e5d7G5fQH0I1PriZkyL6VwsluxywSSfe7HXVYmJzQx0=; b=j7QIPlLlsKLu5gk5UipwJnnLQ8LtPxmS1f5SZ/SaxfIbiat5qTgQMWHY1p9Hcc3C+CRw tak9Bo3+EhuwDbsqvGieLOBTps+nhvqRdhyAS10yt5RXW2kr2PG4bpOP0bZs5lN5ZlRUe xV/Jlui20M2+z0h0Oa1ykdYP6Mfq1reyDxHVtMoUu7Zc2ekqnik0jSObmoAdIligH/Hi9 L1STP75NgeyzIZgjslR8ONDAUWgoHp3gUeOP730W6eQyu4c8ONbXrghezLpVuN36SXRtO xhvGZoXgbTXoqp6gnHO6MV9VJylNhKq8ZnXSpTLEW5i1tIQadX+0CEytWY6tXru//AQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=d4auUGBn; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3359606A33B; Sat, 14 Nov 2026 14:44:56 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=d4auUGBn X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.7 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794667496; b=sUtXQH6B3VnoagEU5G87CvDqhk7frs0OZ7uCpAcqIF20ULm2ZiQjza9HJOdGcJpuoSO/ 2buT2T5zqc8XGe3kVOHuG2qnwQSz2NyXrvXp9aM2w/a0cpSGierSlxVktrees+mCdNa77 pF7i8UniOATS2Eg+7ejvJZIS+OUFP6GubPn0cwKRFoiCVZj2Kg7Poub08S6T2eKPB+AJ4 jDZZz/v19uCIp2s2EI3KFZoIdIpp2g3/cWQFHBwOl9xM2PcArAG2msBu4wfFvK6AFFLrJ zm/YKHSBVSVxe/cH5A/FjFQme25a2C5RuquWwcxVlEr/TCai1XfVVR42vx+VPB3sSDQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794667496; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=e5d7G5fQH0I1PriZkyL6VwsluxywSSfe7HXVYmJzQx0=; b=ytaSoByXEaqlaDW3fGOwFk7QzctD2Gfdw74CV8vCOkOFyYe24zYup1Kcq1SukTuwoTro QWRo+HcEzVBKn1OyUpp6dV7ZX8+wbUOd7hKzz4yb9gPjDcyOGrVDPc9PclWHVqcBStjZ+ t0g1KoYhkjGHbNTWYjVSW/xOXwaq77FNuPy0r/Z5yfSLbBMMvNk02lcQZOSHKuotc/kVd dREyS6FeWNWwpGDkPYwPiNG7PSUgRnNMrN7thP28zXxyZjxu5YpwiXGixxjhRx3X9F8es rdk3CQkeTxCcVqLiG4uvs6AimGFb3ZDuDKcsCFj8I2GVPsC35DgmHGRi5N41RHxUVNw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=d4auUGBn; arc=none smtp.remote-ip=117.135.210.7 X-Received: from m16.mail.126.com (m16.mail.126.com [117.135.210.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BB88606A335; Sat, 14 Nov 2026 14:44:53 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0BB88606A335 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=e5 d7G5fQH0I1PriZkyL6VwsluxywSSfe7HXVYmJzQx0=; b=d4auUGBnlls3f3lucC 4feqjnvupNI/TFEw7DtwEY1GTPk/OxABGbuul5box5H0inHyZ7ZUo/pD8SyM00Oq NoNHCsYzhU7ltOHK4m2AkvDmuAmErHeao8VZFKkLyLXgTJ/XYtHZaZUvG4iUHOYJ f/wBANQQOPLnuSuWZnpfIjqEg= X-Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g1-2 (Coremail) with SMTP id _____wDXjyGec_hqHP+kDA--.56701S5; Sat, 14 Nov 2026 22:43:46 +0800 (CST) X-Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: git-send-email 2.28.0.windows.1 X-In-Reply-To: <20261114144325.816-1-jinvas@126.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-CM-TRANSID: _____wDXjyGec_hqHP+kDA--.56701S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxXrW3Ww1Utr1fJFW5XFWrKrg_yoW5Jw4DpF sxGryDKF1DJ3WxJa1kZ3y0q3s3Ca18JayrC3WSk3y3twnxJr1F9FWru343CFy7CF4rJasF qw15Zw17AF9xGa7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pKsjjiUUUUU= X-CM-SenderInfo: xmlq4tbv6rjloofrz/xtbBswLddGr4c6K5MAAA3S