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 352EC2E36FB for ; Tue, 7 Oct 2025 15:20:53 +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=1759850453; cv=none; b=FUXJ+HSJ9+qUTewIDI+o8SNOlzE7C+xy/ofBMUcvvEhc7hu31vas7QmnCDI2AjNm5tZXNF8byNBXT4SALbT3jKnJrEbTPfmnmhtK5b86x3fkg/n0RY1W6tHxLvhUx3+Hx0QgvF1LcrPaigdfidyTvRUhcCj44nojIFmg4vK7LiA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759850453; c=relaxed/simple; bh=+8ADaXIQIdFZvbSyssi8gzMKd7p2S10XV1XJcJbJBY4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GI0b5YpbLSN/KHrk8x5DQ8E87pwjDlTSU8YiIo43TZo6MbZjnbundwEDGzicDPw7eTYR9cTlR+niagI0WzwSU+xB5xI8r2BF8YArb54lVJn/zymz2vmnvsAHmcbFwUW4x6Dty8SywC6WRa0UMrwEmMviXGPD1ZKmVpnGkACePvQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lYcldZ/H; 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="lYcldZ/H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEE92C4CEF1; Tue, 7 Oct 2025 15:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1759850453; bh=+8ADaXIQIdFZvbSyssi8gzMKd7p2S10XV1XJcJbJBY4=; h=From:To:Cc:Subject:Date:Reply-to:From; b=lYcldZ/HvEHqbnhzHYSNcSaa3qz2AXQZCvMzAsAWNUMXCtsoSwW/3LRY9xsF2CP2c IQSo4XbBqeTmrvio1ghyleGmQ0G0zfUo4YEXhakE6qFppifaj1EHwQORzTYdz28PGr jPJpVju35e94GHfsE2ZpP7ktI7yIjYGH9GDIl1MM= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-53623: mm/swap: fix swap_info_struct race between swapoff and get_swap_pages() Date: Tue, 7 Oct 2025 17:19:28 +0200 Message-ID: <2025100710-CVE-2023-53623-2687@gregkh> X-Mailer: git-send-email 2.51.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=6334; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=fbKaGVRAqTgqTbCt0NYSirH5uSZ/9+aasuQ7JheW5pQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlP9fOO28aVrbnMdM55QaTB0QeZflHbvd9OSY/hj2/65 NZ0+SFPRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEzk4E+GBScfHyzuPzy/8vLn KVKWE3l5eGdPX8Awmy2fW9jk3s+qF59r5uraqx/457PRBAA= 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: mm/swap: fix swap_info_struct race between swapoff and get_swap_pages() The si->lock must be held when deleting the si from the available list. Otherwise, another thread can re-add the si to the available list, which can lead to memory corruption. The only place we have found where this happens is in the swapoff path. This case can be described as below: core 0 core 1 swapoff del_from_avail_list(si) waiting try lock si->lock acquire swap_avail_lock and re-add si into swap_avail_head acquire si->lock but missing si already being added again, and continuing to clear SWP_WRITEOK, etc. It can be easily found that a massive warning messages can be triggered inside get_swap_pages() by some special cases, for example, we call madvise(MADV_PAGEOUT) on blocks of touched memory concurrently, meanwhile, run much swapon-swapoff operations (e.g. stress-ng-swap). However, in the worst case, panic can be caused by the above scene. In swapoff(), the memory used by si could be kept in swap_info[] after turning off a swap. This means memory corruption will not be caused immediately until allocated and reset for a new swap in the swapon path. A panic message caused: (with CONFIG_PLIST_DEBUG enabled) ------------[ cut here ]------------ top: 00000000e58a3003, n: 0000000013e75cda, p: 000000008cd4451a prev: 0000000035b1e58a, n: 000000008cd4451a, p: 000000002150ee8d next: 000000008cd4451a, n: 000000008cd4451a, p: 000000008cd4451a WARNING: CPU: 21 PID: 1843 at lib/plist.c:60 plist_check_prev_next_node+0x50/0x70 Modules linked in: rfkill(E) crct10dif_ce(E)... CPU: 21 PID: 1843 Comm: stress-ng Kdump: ... 5.10.134+ Hardware name: Alibaba Cloud ECS, BIOS 0.0.0 02/06/2015 pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--) pc : plist_check_prev_next_node+0x50/0x70 lr : plist_check_prev_next_node+0x50/0x70 sp : ffff0018009d3c30 x29: ffff0018009d3c40 x28: ffff800011b32a98 x27: 0000000000000000 x26: ffff001803908000 x25: ffff8000128ea088 x24: ffff800011b32a48 x23: 0000000000000028 x22: ffff001800875c00 x21: ffff800010f9e520 x20: ffff001800875c00 x19: ffff001800fdc6e0 x18: 0000000000000030 x17: 0000000000000000 x16: 0000000000000000 x15: 0736076307640766 x14: 0730073007380731 x13: 0736076307640766 x12: 0730073007380731 x11: 000000000004058d x10: 0000000085a85b76 x9 : ffff8000101436e4 x8 : ffff800011c8ce08 x7 : 0000000000000000 x6 : 0000000000000001 x5 : ffff0017df9ed338 x4 : 0000000000000001 x3 : ffff8017ce62a000 x2 : ffff0017df9ed340 x1 : 0000000000000000 x0 : 0000000000000000 Call trace: plist_check_prev_next_node+0x50/0x70 plist_check_head+0x80/0xf0 plist_add+0x28/0x140 add_to_avail_list+0x9c/0xf0 _enable_swap_info+0x78/0xb4 __do_sys_swapon+0x918/0xa10 __arm64_sys_swapon+0x20/0x30 el0_svc_common+0x8c/0x220 do_el0_svc+0x2c/0x90 el0_svc+0x1c/0x30 el0_sync_handler+0xa8/0xb0 el0_sync+0x148/0x180 irq event stamp: 2082270 Now, si->lock locked before calling 'del_from_avail_list()' to make sure other thread see the si had been deleted and SWP_WRITEOK cleared together, will not reinsert again. This problem exists in versions after stable 5.10.y. The Linux kernel CVE team has assigned CVE-2023-53623 to this issue. Affected and fixed versions =========================== Issue introduced in 4.14 with commit a2468cc9bfdff6139f59ca896671e5819ff5f94a and fixed in 4.14.313 with commit 111a79d9b92f0a679fe300ccd3119ae9741f3d54 Issue introduced in 4.14 with commit a2468cc9bfdff6139f59ca896671e5819ff5f94a and fixed in 4.19.281 with commit a55f268abdb74ac5633b75a09fefb58458e9d2a2 Issue introduced in 4.14 with commit a2468cc9bfdff6139f59ca896671e5819ff5f94a and fixed in 5.4.241 with commit e7bba7ddb4318d5ea939c8db747c2c2780ab66f4 Issue introduced in 4.14 with commit a2468cc9bfdff6139f59ca896671e5819ff5f94a and fixed in 5.10.178 with commit ea8c42b3b6d95ced3a4f555f04686d00ef0bb206 Issue introduced in 4.14 with commit a2468cc9bfdff6139f59ca896671e5819ff5f94a and fixed in 5.15.107 with commit 4bdf1514b4268d29360ba9e43becdd49955bc7ae Issue introduced in 4.14 with commit a2468cc9bfdff6139f59ca896671e5819ff5f94a and fixed in 6.1.24 with commit 85cc118ce6f1a627901b6db50c9d01f2ad78cdbf Issue introduced in 4.14 with commit a2468cc9bfdff6139f59ca896671e5819ff5f94a and fixed in 6.2.11 with commit b9927d3a60ca9ed35625470888629c074e687ba0 Issue introduced in 4.14 with commit a2468cc9bfdff6139f59ca896671e5819ff5f94a and fixed in 6.3 with commit 6fe7d6b992113719e96744d974212df3fcddc76c 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-2023-53623 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: mm/swapfile.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/111a79d9b92f0a679fe300ccd3119ae9741f3d54 https://git.kernel.org/stable/c/a55f268abdb74ac5633b75a09fefb58458e9d2a2 https://git.kernel.org/stable/c/e7bba7ddb4318d5ea939c8db747c2c2780ab66f4 https://git.kernel.org/stable/c/ea8c42b3b6d95ced3a4f555f04686d00ef0bb206 https://git.kernel.org/stable/c/4bdf1514b4268d29360ba9e43becdd49955bc7ae https://git.kernel.org/stable/c/85cc118ce6f1a627901b6db50c9d01f2ad78cdbf https://git.kernel.org/stable/c/b9927d3a60ca9ed35625470888629c074e687ba0 https://git.kernel.org/stable/c/6fe7d6b992113719e96744d974212df3fcddc76c