From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl2-f12.google.com (mail-dl2-f12.google.com [74.125.229.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B13F236197E for ; Fri, 2 Oct 2026 20:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.140 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790973886; cv=none; b=O3+BkO+HC05cDeowF+VeB0Y3fVE/d/JYjRQeHRPPdI67P83ZkeqwjFG2uqcImfHnIkhDvB86nkQmU24grOPyw08A70fp7VMUBPJBOvzzpBA1Ng+8tz5W0I94ncxCGU26HiR82X3rQ+6wjIdEGgq4tIBlUFioLPYnPVZtGsJZ5ys= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790973886; c=relaxed/simple; bh=hSIz4fihW3br2vB9KwOROSdJNfpPnljc28909L6iTQc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=q8CJShNcb8NzvISJrlmxMRhAR67gX6Sz7FnCe5Z7O/NRFmtVEaz7wSXWT/31zoBfg15YLMhKQ66iPGRnbmyik6aZ4eHRQrvz4YQKbHm7VP3L85sU3bc9KqCqM1gIsJg/RwVCKTlF3Wwj1XnPA8lfQyX6+YTe1cLTXd5WBwzMD5o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com; spf=pass smtp.mailfrom=trailofbits.com; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b=jQsVdQsV; arc=none smtp.client-ip=74.125.229.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b="jQsVdQsV" Received: by mail-dl2-f12.google.com with SMTP id a92af1059eb24-142dd04f7f2so19445c88.0 for ; Fri, 02 Oct 2026 13:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trailofbits.com; s=google; t=1790973884; x=1791578684; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=OEUMUqkSZXNw7bjqr2r2LczcRXo92A7RQr8KDcVvERk=; b=jQsVdQsVWc3c8yE2thqgmluoZvBX2TrWNc3UO05+/MpwQXaOvTRttMWO8ZMPg974qM 9rOnxQDlZvHaGyO55KM60gMyQdBe8zEoQ3H1Qd0iEnK//WFts6Jd1AIqpcL0hy/QP0ol 2TSuJBbivop5R90MX5n09dsmqjC4t+OhdjN3U6P6jTyCnSQdUJZDU4WdEejFLLJsbZpE ArxDrkgAgjVVfvc2ZTsUsObJNfgV5Bba90gcm4/JpTI0GrGc9G12QxyM4u80CpcrxJ6W nIBp/OAb3M9hU9+SEuGmcY+O/wO6QJwoTkRKXX/HbarQ77WaiyzBGt/GXK2bE4UCaD8E LpIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790973884; x=1791578684; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OEUMUqkSZXNw7bjqr2r2LczcRXo92A7RQr8KDcVvERk=; b=mXoYhv1HdrPJNytXc+RcHZJHTj6bb2eOXgGGCYo8khGvCURYqHECrUqIWZMm1PSuyr QgNKjQGi2CoDu0rljazkuQQa/Eq/14RR+lc0DGlx9rPb3wpn0zask4YOLQt5iCQF/9v5 C5VirQGAuAhA/wyFo93JiunxFN+VPQ6VROTY312d+0DqVqA16+sopikyWzi7Hpz7HmgP feREWiNmVDKNrOp3ncjBsuTO1PEGU6e9iFgytz4lcTJA0L0OpG3GUKmf5aDxPWowpE7p GpEHuCJo7uoP8LOMoZ9CN4/0p4XD10ulIVgCB3V52zjq0ly7JpfS/R30qkmZIERrfmlj KWZQ== X-Forwarded-Encrypted: i=1; AKwUvByBn3Ft60im74quBR2iPsl4FD4gusAAD+JJM9G2T+zvxLwcEpSPyE/j5cuKStdd+ItfgeWvDmCUMInOTlU=@vger.kernel.org X-Gm-Message-State: AFq9FYJP5ZvNndq9X+edmeANnHLZSV+KUnU8t2tD3PaQBj83OB8xXkG/ tUThivpgoLkX8L4U9LLJOC16CsXrGiGVKA+q0lnwDB5+IrpD9kQn98PohXCO/gB+q20= X-Gm-Gg: AYBFou35DN5X0kmuvEu8bAkQ6KPOqzJFVsguq7I9CrO+mgAOqUwoM2xgWVKsCS6rIIf 1gJBOJj4KQDzTGNwAuKBrvJmvUcJw4f4GeTgyqAlm8v7Rq09/tvp2GNC2xbzilwiH0Xo2zjZfuO L7lBQDnp82S2+YBdxkHQ4GLqumLOpyhzrU4IRi7SbOkvS5bOV8Y4ykq4dSUr/jSoClHidiMcl0L Lh+mOgVTCfL+5jY4lkbFJ96pbjE0z1dr0bGwv35zG8sM4IVAovxATJ8NJ0+VgkNV1QntCtDdtRN +q+rMYcJfdiVFCRJDQwMQe0Cbo1zRRyuKkdSMGHbUDgrdIALIbyQRPkF3ZsLPsHHoW1eUNXgPfP HaqkX7c31A2hZ0anp+1kGxg5ry+/pBOQIAGOkxqUmjGhoutENInk1H/XCvFXteBDlMAWHWgbj1g kADXFXYzB77YAcQ4NVbTQj57A/vniHYNf6z41sGD/VvM9An0YI98IFfMVfng6J/xZh6qdQMyzY1 MrprnX8Wf3gTCh8vtEAge++hFOoRYvSW/VZVxTQgSkvJVIdagT6l35q3Pocq5muTVivAWc= X-Received: by 2002:a05:701b:4190:10b0:148:dfc9:425d with SMTP id a92af1059eb24-14f5d1b9c76mr4478202c88.46.1790973883634; Fri, 02 Oct 2026 13:44:43 -0700 (PDT) Received: from localhost.localdomain ([2603:8001:5f01:8bab:a1e3:ffe2:b35a:69a4]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-151fa74fa1csm23201c88.1.2026.10.02.13.44.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 02 Oct 2026 13:44:43 -0700 (PDT) From: Artem Dinaburg To: stable@vger.kernel.org Cc: Artem Dinaburg , Greg Kroah-Hartman , Sasha Levin , Shay Drory , Tariq Toukan , Simon Horman , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Bloch , Leon Romanovsky , Andrew Lunn Subject: [PATCH 6.1.y] net/mlx5e: Fix netif state handling Date: Fri, 2 Oct 2026 16:44:37 -0400 Message-ID: <20261002204438.26168-1-artem@trailofbits.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Shay Drory [ Upstream commit 3d5918477f94e4c2f064567875c475468e264644 ] mlx5e_suspend cleans resources only if netif_device_present() returns true. However, mlx5e_resume changes the state of netif, via mlx5e_nic_enable, only if reg_state == NETREG_REGISTERED. In the below case, the above leads to NULL-ptr Oops[1] and memory leaks: mlx5e_probe _mlx5e_resume mlx5e_attach_netdev mlx5e_nic_enable <-- netdev not reg, not calling netif_device_attach() register_netdev <-- failed for some reason. ERROR_FLOW: _mlx5e_suspend <-- netif_device_present return false, resources aren't freed :( Hence, clean resources in this case as well. [1] BUG: kernel NULL pointer dereference, address: 0000000000000000 PGD 0 P4D 0 Oops: 0010 [#1] SMP CPU: 2 PID: 9345 Comm: test-ovs-ct-gen Not tainted 6.5.0_for_upstream_min_debug_2023_09_05_16_01 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:0x0 Code: Unable to access opcode bytes at0xffffffffffffffd6. RSP: 0018:ffff888178aaf758 EFLAGS: 00010246 Call Trace: ? __die+0x20/0x60 ? page_fault_oops+0x14c/0x3c0 ? exc_page_fault+0x75/0x140 ? asm_exc_page_fault+0x22/0x30 notifier_call_chain+0x35/0xb0 blocking_notifier_call_chain+0x3d/0x60 mlx5_blocking_notifier_call_chain+0x22/0x30 [mlx5_core] mlx5_core_uplink_netdev_event_replay+0x3e/0x60 [mlx5_core] mlx5_mdev_netdev_track+0x53/0x60 [mlx5_ib] mlx5_ib_roce_init+0xc3/0x340 [mlx5_ib] __mlx5_ib_add+0x34/0xd0 [mlx5_ib] mlx5r_probe+0xe1/0x210 [mlx5_ib] ? auxiliary_match_id+0x6a/0x90 auxiliary_bus_probe+0x38/0x80 ? driver_sysfs_add+0x51/0x80 really_probe+0xc9/0x3e0 ? driver_probe_device+0x90/0x90 __driver_probe_device+0x80/0x160 driver_probe_device+0x1e/0x90 __device_attach_driver+0x7d/0x100 bus_for_each_drv+0x80/0xd0 __device_attach+0xbc/0x1f0 bus_probe_device+0x86/0xa0 device_add+0x637/0x840 __auxiliary_device_add+0x3b/0xa0 add_adev+0xc9/0x140 [mlx5_core] mlx5_rescan_drivers_locked+0x22a/0x310 [mlx5_core] mlx5_register_device+0x53/0xa0 [mlx5_core] mlx5_init_one_devl_locked+0x5c4/0x9c0 [mlx5_core] mlx5_init_one+0x3b/0x60 [mlx5_core] probe_one+0x44c/0x730 [mlx5_core] local_pci_probe+0x3e/0x90 pci_device_probe+0xbf/0x210 ? kernfs_create_link+0x5d/0xa0 ? sysfs_do_create_link_sd+0x60/0xc0 really_probe+0xc9/0x3e0 ? driver_probe_device+0x90/0x90 __driver_probe_device+0x80/0x160 driver_probe_device+0x1e/0x90 __device_attach_driver+0x7d/0x100 bus_for_each_drv+0x80/0xd0 __device_attach+0xbc/0x1f0 pci_bus_add_device+0x54/0x80 pci_iov_add_virtfn+0x2e6/0x320 sriov_enable+0x208/0x420 mlx5_core_sriov_configure+0x9e/0x200 [mlx5_core] sriov_numvfs_store+0xae/0x1a0 kernfs_fop_write_iter+0x10c/0x1a0 vfs_write+0x291/0x3c0 ksys_write+0x5f/0xe0 do_syscall_64+0x3d/0x90 entry_SYSCALL_64_after_hwframe+0x46/0xb0 CR2: 0000000000000000 ---[ end trace 0000000000000000 ]--- [ Backport to 6.1.y: added an internal suspend helper so probe unwind cleans resources without changing the registered-device suspend path. ] Fixes: 2c3b5beec46a ("net/mlx5e: More generic netdev management API") Signed-off-by: Shay Drory Signed-off-by: Tariq Toukan Reviewed-by: Simon Horman Link: https://lore.kernel.org/r/20240509112951.590184-2-tariqt@nvidia.com Signed-off-by: Jakub Kicinski Assisted-by: LLM Signed-off-by: Artem Dinaburg --- Hi Greg, Sasha, and net maintainers, I am working through the small CVE backports still missing from 6.1.y. This one addresses CVE-2024-38608. It releases probe resources even when register_netdev() failed before device-present state. The corresponding 6.6.y backport is already in the 6.6.y stable queue. The fix is already present in 6.12.y, 6.18.y, and 7.2.y, but not in 6.1.y. The target-specific adjustment is recorded in the bracketed note above. Could you please queue it for 6.1.y? CVE: CVE-2024-38608 Upstream: 3d5918477f94e4c2f064567875c475468e264644 AI assistance: An LLM helped identify, adapt, and validate this backport; I reviewed the resulting code and validation evidence. Thanks, Artem Dinaburg drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 2d0b57583ea35c..d26c36479ee915 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5896,13 +5896,14 @@ static int mlx5e_resume(struct auxiliary_device *adev) return 0; } -static int mlx5e_suspend(struct auxiliary_device *adev, pm_message_t state) +static int mlx5e_suspend_common(struct auxiliary_device *adev, + bool pre_netdev_reg) { struct mlx5e_priv *priv = auxiliary_get_drvdata(adev); struct net_device *netdev = priv->netdev; struct mlx5_core_dev *mdev = priv->mdev; - if (!netif_device_present(netdev)) { + if (!pre_netdev_reg && !netif_device_present(netdev)) { if (test_bit(MLX5E_STATE_DESTROYING, &priv->state)) mlx5e_destroy_mdev_resources(mdev); return -ENODEV; @@ -5913,6 +5914,11 @@ static int mlx5e_suspend(struct auxiliary_device *adev, pm_message_t state) return 0; } +static int mlx5e_suspend(struct auxiliary_device *adev, pm_message_t state) +{ + return mlx5e_suspend_common(adev, false); +} + static int mlx5e_probe(struct auxiliary_device *adev, const struct auxiliary_device_id *id) { @@ -5920,7 +5926,6 @@ static int mlx5e_probe(struct auxiliary_device *adev, const struct mlx5e_profile *profile = &mlx5e_nic_profile; struct mlx5_core_dev *mdev = edev->mdev; struct net_device *netdev; - pm_message_t state = {}; struct mlx5e_priv *priv; int err; @@ -5969,7 +5974,7 @@ static int mlx5e_probe(struct auxiliary_device *adev, return 0; err_resume: - mlx5e_suspend(adev, state); + mlx5e_suspend_common(adev, true); err_profile_cleanup: profile->cleanup(priv); err_devlink_cleanup: -- 2.39.5