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 E2CBC288520 for ; Wed, 18 Jun 2025 11:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750244779; cv=none; b=dL1pihDDr2b6YMC9tDNit34sRgiDWxr/JQ4WEuvsmu0nMmp08PfkoUGIm+wTYQb86zhnzRdkxGaTlFo7O0p+fWMEPy1ConnnQsdz+2S19AsNuO3fr3at8ayJ21VuYM4oJmF7ixnVU4q58I/rA5DYatXO0B0KQ3PbSAmoC3l2xaY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750244779; c=relaxed/simple; bh=TsgdTTLqcaRhqqNOVFVmpg3YGIl98Sb3KQ9S3GICOg4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=c1ybQU+mQb/jILOZ282Ivk1NGxXDZIW3watGQWViPZXwKPOYACUfxphk2KgL9GOUOZXS73Hn66+ca7vHO3HKpcc1J+AaadRfeOMtI1g493w73LJXFSFH7i9EYxXIxz6m91uf9DpsapKIfoEKo8pRrzDvKSiTsYpk7XgOklRqlU0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TIy3m8e+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TIy3m8e+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A56CC4CEE7; Wed, 18 Jun 2025 11:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750244778; bh=TsgdTTLqcaRhqqNOVFVmpg3YGIl98Sb3KQ9S3GICOg4=; h=From:To:Cc:Subject:Date:Reply-to:From; b=TIy3m8e+HqEm3EG/sZkn7/buUBCVVcHd6L4ud+VDxBueZFz2lFk2zrBiizheP8FSd WCNOVbsRuvdXuU2+vOvuy53Z+AwhOJx6i28MtcAOprVcboqc+TuN4zpt789dz5qWdW T0ctKnEQsAwPh87ip0naeR8yXO5xOTwheW1LolGY= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50002: net/mlx5: LAG, fix logic over MLX5_LAG_FLAG_NDEVS_READY Date: Wed, 18 Jun 2025 13:01:07 +0200 Message-ID: <2025061828-CVE-2022-50002-9e5f@gregkh> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4570; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=GWGTuMrZT2lEjLdee4zDPKms18m5n3Qb9ZxbNgD5RmI=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlBc3w+mJvFTL+TOP0Cm/Pdku6l7k8+JCWXHZmurOpyW GtFf8ChjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjIQU6GBctCFgssmn9gYe3h /PSOSXWi52xnpDIs2K33OLlp/ssrZ0pTXf6vfnfqzJtJcgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: net/mlx5: LAG, fix logic over MLX5_LAG_FLAG_NDEVS_READY Only set MLX5_LAG_FLAG_NDEVS_READY if both netdevices are registered. Doing so guarantees that both ldev->pf[MLX5_LAG_P0].dev and ldev->pf[MLX5_LAG_P1].dev have valid pointers when MLX5_LAG_FLAG_NDEVS_READY is set. The core issue is asymmetry in setting MLX5_LAG_FLAG_NDEVS_READY and clearing it. Setting it is done wrongly when both ldev->pf[MLX5_LAG_P0].dev and ldev->pf[MLX5_LAG_P1].dev are set; clearing it is done right when either of ldev->pf[i].netdev is cleared. Consider the following scenario: 1. PF0 loads and sets ldev->pf[MLX5_LAG_P0].dev to a valid pointer 2. PF1 loads and sets both ldev->pf[MLX5_LAG_P1].dev and ldev->pf[MLX5_LAG_P1].netdev with valid pointers. This results in MLX5_LAG_FLAG_NDEVS_READY is set. 3. PF0 is unloaded before setting dev->pf[MLX5_LAG_P0].netdev. MLX5_LAG_FLAG_NDEVS_READY remains set. Further execution of mlx5_do_bond() will result in null pointer dereference when calling mlx5_lag_is_multipath() This patch fixes the following call trace actually encountered: [ 1293.475195] BUG: kernel NULL pointer dereference, address: 00000000000009a8 [ 1293.478756] #PF: supervisor read access in kernel mode [ 1293.481320] #PF: error_code(0x0000) - not-present page [ 1293.483686] PGD 0 P4D 0 [ 1293.484434] Oops: 0000 [#1] SMP PTI [ 1293.485377] CPU: 1 PID: 23690 Comm: kworker/u16:2 Not tainted 5.18.0-rc5_for_upstream_min_debug_2022_05_05_10_13 #1 [ 1293.488039] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 [ 1293.490836] Workqueue: mlx5_lag mlx5_do_bond_work [mlx5_core] [ 1293.492448] RIP: 0010:mlx5_lag_is_multipath+0x5/0x50 [mlx5_core] [ 1293.494044] Code: e8 70 40 ff e0 48 8b 14 24 48 83 05 5c 1a 1b 00 01 e9 19 ff ff ff 48 83 05 47 1a 1b 00 01 eb d7 0f 1f 44 00 00 0f 1f 44 00 00 <48> 8b 87 a8 09 00 00 48 85 c0 74 26 48 83 05 a7 1b 1b 00 01 41 b8 [ 1293.498673] RSP: 0018:ffff88811b2fbe40 EFLAGS: 00010202 [ 1293.500152] RAX: ffff88818a94e1c0 RBX: ffff888165eca6c0 RCX: 0000000000000000 [ 1293.501841] RDX: 0000000000000001 RSI: ffff88818a94e1c0 RDI: 0000000000000000 [ 1293.503585] RBP: 0000000000000000 R08: ffff888119886740 R09: ffff888165eca73c [ 1293.505286] R10: 0000000000000018 R11: 0000000000000018 R12: ffff88818a94e1c0 [ 1293.506979] R13: ffff888112729800 R14: 0000000000000000 R15: ffff888112729858 [ 1293.508753] FS: 0000000000000000(0000) GS:ffff88852cc40000(0000) knlGS:0000000000000000 [ 1293.510782] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1293.512265] CR2: 00000000000009a8 CR3: 00000001032d4002 CR4: 0000000000370ea0 [ 1293.514001] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1293.515806] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 The Linux kernel CVE team has assigned CVE-2022-50002 to this issue. Affected and fixed versions =========================== Issue introduced in 5.14 with commit 8a66e45859797e5dd77ff17dd37781f99d5f5b9b and fixed in 5.19.6 with commit 4c040acf5744e87a7b3490f9ec8bedd0d15c9f29 Issue introduced in 5.14 with commit 8a66e45859797e5dd77ff17dd37781f99d5f5b9b and fixed in 6.0 with commit a6e675a66175869b7d87c0e1dd0ddf93e04f8098 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2022-50002 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/4c040acf5744e87a7b3490f9ec8bedd0d15c9f29 https://git.kernel.org/stable/c/a6e675a66175869b7d87c0e1dd0ddf93e04f8098