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 5A6DB1CC16C for ; Thu, 7 Nov 2024 09:36:05 +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=1730972165; cv=none; b=okZgJMkhMJCVDmmoLA17sqzKjC3akwgGbGN02Yf7N7dQWKPtS6wAjRW/u9XOUCDioMYDWCps3UtHPE3cuaz2Pd1KZs2akGoTTOJLT9RNxfmtOZ1QrHD2g/8BxmOa7WArd5BHuZRgYN5HXcvZj5qGKUkxlwko7FG6DKEsnzoSO30= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730972165; c=relaxed/simple; bh=QfGeAbMIrG4ZaKHjuFW3holjSQWwYjMq0ONF2ObxruM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=R2+vX1AGpm0zXCS4redWMp30oylZoSP7wqZkSV2ePxJCtu9oR+4jXL7fWDl9+gmc0nIT3a6tvj+N0t6I8Rm5pytN7/FGnUgjX3NgJhgt/Oqs/VGrTkrVltMBly0lu+gFnhqYZdLN+4v9F9mbQWUt1J6A2Mn7lTq4O7FV9+bIwD4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=r2i0I9ph; 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="r2i0I9ph" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADF74C4CECC; Thu, 7 Nov 2024 09:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730972165; bh=QfGeAbMIrG4ZaKHjuFW3holjSQWwYjMq0ONF2ObxruM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=r2i0I9phV+XHwwdbRa4Tdn0MaZm51hrS94U8H+OBY4seunbwqHBmwkaQNgh4u3oJh +HdcCQYjShl9L5WC5MNEL0sRD1OJIyARrSUe7Zq8HJXSq6DpaPJocuNkynhIGTkjbk Ogt65PGOOLfgIIw6W5Ojw456VMEwQhTStAFDXmJE= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-50147: net/mlx5: Fix command bitmask initialization Date: Thu, 7 Nov 2024 10:34:47 +0100 Message-ID: <2024110744-CVE-2024-50147-d5b6@gregkh> X-Mailer: git-send-email 2.47.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=3776; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=QfGeAbMIrG4ZaKHjuFW3holjSQWwYjMq0ONF2ObxruM=; b=owGbwMvMwCRo6H6F97bub03G02pJDOk6nVtmXPxmnZN+I9HWytOUdYf4+8vLRWRrqtaVamm/n Xo4dbdoRwwLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEzkdR/DbNbk1x5VNT1HL6mW c0VWMEer3jp4gWHGLGGd6Yv4ZI7ZX5l3t0hZ/51WnisA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: net/mlx5: Fix command bitmask initialization Command bitmask have a dedicated bit for MANAGE_PAGES command, this bit isn't Initialize during command bitmask Initialization, only during MANAGE_PAGES. In addition, mlx5_cmd_trigger_completions() is trying to trigger completion for MANAGE_PAGES command as well. Hence, in case health error occurred before any MANAGE_PAGES command have been invoke (for example, during mlx5_enable_hca()), mlx5_cmd_trigger_completions() will try to trigger completion for MANAGE_PAGES command, which will result in null-ptr-deref error.[1] Fix it by Initialize command bitmask correctly. While at it, re-write the code for better understanding. [1] BUG: KASAN: null-ptr-deref in mlx5_cmd_trigger_completions+0x1db/0x600 [mlx5_core] Write of size 4 at addr 0000000000000214 by task kworker/u96:2/12078 CPU: 10 PID: 12078 Comm: kworker/u96:2 Not tainted 6.9.0-rc2_for_upstream_debug_2024_04_07_19_01 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Workqueue: mlx5_health0000:08:00.0 mlx5_fw_fatal_reporter_err_work [mlx5_core] Call Trace: dump_stack_lvl+0x7e/0xc0 kasan_report+0xb9/0xf0 kasan_check_range+0xec/0x190 mlx5_cmd_trigger_completions+0x1db/0x600 [mlx5_core] mlx5_cmd_flush+0x94/0x240 [mlx5_core] enter_error_state+0x6c/0xd0 [mlx5_core] mlx5_fw_fatal_reporter_err_work+0xf3/0x480 [mlx5_core] process_one_work+0x787/0x1490 ? lockdep_hardirqs_on_prepare+0x400/0x400 ? pwq_dec_nr_in_flight+0xda0/0xda0 ? assign_work+0x168/0x240 worker_thread+0x586/0xd30 ? rescuer_thread+0xae0/0xae0 kthread+0x2df/0x3b0 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x2d/0x70 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork_asm+0x11/0x20 The Linux kernel CVE team has assigned CVE-2024-50147 to this issue. Affected and fixed versions =========================== Issue introduced in 6.1 with commit 9b98d395b85d and fixed in 6.1.115 with commit d1606090bb29 Issue introduced in 6.1 with commit 9b98d395b85d and fixed in 6.6.59 with commit d88564c79d1c Issue introduced in 6.1 with commit 9b98d395b85d and fixed in 6.11.6 with commit 2feac1e562be Issue introduced in 6.1 with commit 9b98d395b85d and fixed in 6.12-rc4 with commit d62b14045c65 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-2024-50147 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/cmd.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/d1606090bb294cecb7de3c4ed177f5aa0abd4c4e https://git.kernel.org/stable/c/d88564c79d1cedaf2655f12261eca0d2796bde4e https://git.kernel.org/stable/c/2feac1e562be0efc621a6722644a90f355d53473 https://git.kernel.org/stable/c/d62b14045c6511a7b2d4948d1a83a4e592deeb05