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 7D82D1F4727 for ; Fri, 27 Dec 2024 15:00:22 +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=1735311622; cv=none; b=o0FlF+ZVT1WvB2H1bIFqpMHidN+SRDXiRAZkiV5KlNdU2jO0l5RP86ttGJFrmIzT31/TwJczYFIyaU54yKBJgMqTUMyueXb+GGP5AAsSdThqdNMgzwnIz9Ijm6oExyDgkKnheTLH7aYMb8xC7dLmG2pVHpaxEXRJ4CFahnDCERU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735311622; c=relaxed/simple; bh=6vnmgYujsZXkUZCRzq+VrGfPzrgLOdGhlsOicyVEfCE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EEKLaNeEORkdGL5Zxk1Of5mB6/Isie7msXjjwXZBzms+kXPnSEgHcLWYq9m5acKeK4zWGs/1MY6Uhrb3TkVFrw671w/EC/vLO163tXP5jb8rPuFekwBZLcG5cKecOg10bHJyusBUUj2KGNX5ZPz4tGcnhV9+XRnuZ4DcuoV95NM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=B+IptLJb; 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="B+IptLJb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF80AC4CED0; Fri, 27 Dec 2024 15:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735311622; bh=6vnmgYujsZXkUZCRzq+VrGfPzrgLOdGhlsOicyVEfCE=; h=From:To:Cc:Subject:Date:Reply-to:From; b=B+IptLJb4afsCW0JT5q/C04nvxr2+YyfwL6KFtInRnqfyM9bHDM7+WPmsAQ+Zwril weaquKx59cPOqZPnK+8vOBbCMtNNL1/Rf3SVXvlPfowoG5vq3CaPM7zfTrp9/1cYpa 9uG+N7PIfAITP/teuQmkOpxahoXwuhbu/Kr3S/o0= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-56613: sched/numa: fix memory leak due to the overwritten vma->numab_state Date: Fri, 27 Dec 2024 15:51:20 +0100 Message-ID: <2024122707-CVE-2024-56613-0897@gregkh> X-Mailer: git-send-email 2.47.1 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=4163; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=6vnmgYujsZXkUZCRzq+VrGfPzrgLOdGhlsOicyVEfCE=; b=owGbwMvMwCRo6H6F97bub03G02pJDOl5+25PvbcoIG7dtRNqAutfhtQbaGxPXd7NIrw3+hrXh fr13UnGHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRwGcMC27+zZ97e/l5A57M zCxtw65FTHflihgWHHm89b3HByvjxeYhfxqV/givKLF0BwA= 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: sched/numa: fix memory leak due to the overwritten vma->numab_state [Problem Description] When running the hackbench program of LTP, the following memory leak is reported by kmemleak. # /opt/ltp/testcases/bin/hackbench 20 thread 1000 Running with 20*40 (== 800) tasks. # dmesg | grep kmemleak ... kmemleak: 480 new suspected memory leaks (see /sys/kernel/debug/kmemleak) kmemleak: 665 new suspected memory leaks (see /sys/kernel/debug/kmemleak) # cat /sys/kernel/debug/kmemleak unreferenced object 0xffff888cd8ca2c40 (size 64): comm "hackbench", pid 17142, jiffies 4299780315 hex dump (first 32 bytes): ac 74 49 00 01 00 00 00 4c 84 49 00 01 00 00 00 .tI.....L.I..... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc bff18fd4): [] __kmalloc_cache_noprof+0x2f9/0x3f0 [] task_numa_work+0x725/0xa00 [] task_work_run+0x58/0x90 [] syscall_exit_to_user_mode+0x1c8/0x1e0 [] do_syscall_64+0x85/0x150 [] entry_SYSCALL_64_after_hwframe+0x76/0x7e ... This issue can be consistently reproduced on three different servers: * a 448-core server * a 256-core server * a 192-core server [Root Cause] Since multiple threads are created by the hackbench program (along with the command argument 'thread'), a shared vma might be accessed by two or more cores simultaneously. When two or more cores observe that vma->numab_state is NULL at the same time, vma->numab_state will be overwritten. Although current code ensures that only one thread scans the VMAs in a single 'numa_scan_period', there might be a chance for another thread to enter in the next 'numa_scan_period' while we have not gotten till numab_state allocation [1]. Note that the command `/opt/ltp/testcases/bin/hackbench 50 process 1000` cannot the reproduce the issue. It is verified with 200+ test runs. [Solution] Use the cmpxchg atomic operation to ensure that only one thread executes the vma->numab_state assignment. [1] https://lore.kernel.org/lkml/1794be3c-358c-4cdc-a43d-a1f841d91ef7@amd.com/ The Linux kernel CVE team has assigned CVE-2024-56613 to this issue. Affected and fixed versions =========================== Issue introduced in 6.4 with commit ef6a22b70f6d90449a5c797b8968a682824e2011 and fixed in 6.6.66 with commit 8f149bcc4d91ac92b32ff4949b291e6ed883dc42 Issue introduced in 6.4 with commit ef6a22b70f6d90449a5c797b8968a682824e2011 and fixed in 6.12.5 with commit a71ddd5b87cda687efa28e049e85e923689bcef9 Issue introduced in 6.4 with commit ef6a22b70f6d90449a5c797b8968a682824e2011 and fixed in 6.13-rc2 with commit 5f1b64e9a9b7ee9cfd32c6b2fab796e29bfed075 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-56613 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: kernel/sched/fair.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/8f149bcc4d91ac92b32ff4949b291e6ed883dc42 https://git.kernel.org/stable/c/a71ddd5b87cda687efa28e049e85e923689bcef9 https://git.kernel.org/stable/c/5f1b64e9a9b7ee9cfd32c6b2fab796e29bfed075