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 1E2F231A578 for ; Mon, 15 Sep 2025 14:26:01 +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=1757946361; cv=none; b=N/5t6x0+yY6V5cl/g+J86qaXA7o199tsxEIVLiozRM+V35zoeRKzZJov0HvoTsuZlnNP4KPnRsCH8ruPk04tpt7PEBVoWzmjj6inZzyTeJFeFQCmBUTm3CpSduo0hNESzEIXrH8u9AN59K/1mglcbWRbIOn0ViHh24+KHal5m+U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757946361; c=relaxed/simple; bh=VLP7E284EF4Vna8A/c2JitNxd2qvjiizke8QURW6ZIY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=P1O3Z9GnyAC3Ka2xXXCDPriufKXaeLC4dTIOeRivum7k4uVw2g6Bbz5EWsiQ7q8Z0Q30ZvMMW6t0McsR9N+Gzwfje0bzJMvU9Xd2fQPLeDW/Y4Mqv4QrWGKdhKXXqQ8/i6PgA3at+zO7DLjgaHrUiEnonIcehUqBkO5ylifc1PE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HIvdLSaN; 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="HIvdLSaN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16D34C4CEF5; Mon, 15 Sep 2025 14:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757946361; bh=VLP7E284EF4Vna8A/c2JitNxd2qvjiizke8QURW6ZIY=; h=From:To:Cc:Subject:Date:Reply-to:From; b=HIvdLSaNkJC5pbRuRBufB5Nq7/NKBx7Pxj5Jyi1AyHGA2jsdrknaEsIGmB90O28Ok +jaVkiimBj4TQrUsUGtcKLk1VJhyiUNpYxhOaijygH/qgOi3r1HypoD8h+J41BpQjk GAJ6f4PydmhI87amfkYAStlLQ2z/hqthdQzxpUwc= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-53231: erofs: Fix detection of atomic context Date: Mon, 15 Sep 2025 16:22:05 +0200 Message-ID: <2025091514-CVE-2023-53231-7743@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=4068; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=x+qo0HEv/6RVrN5B97gTtMKMZ3g83pW8kthdLMuW45k=; b=owGbwMvMwCRo6H6F97bub03G02pJDBknFG5928f7OrpB1qT6Xm/A8o/fr8w8UN7b+FmY/Xd42 pHUr+/DOmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAibBcZFkw0WBske8xCxm0q A2uo+YnNEsd+HGKY73bj+9oLnGUHrQ8I7tI2DpXaPstrPQA= 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: erofs: Fix detection of atomic context Current check for atomic context is not sufficient as z_erofs_decompressqueue_endio can be called under rcu lock from blk_mq_flush_plug_list(). See the stacktrace [1] In such case we should hand off the decompression work for async processing rather than trying to do sync decompression in current context. Patch fixes the detection by checking for rcu_read_lock_any_held() and while at it use more appropriate !in_task() check than in_atomic(). Background: Historically erofs would always schedule a kworker for decompression which would incur the scheduling cost regardless of the context. But z_erofs_decompressqueue_endio() may not always be in atomic context and we could actually benefit from doing the decompression in z_erofs_decompressqueue_endio() if we are in thread context, for example when running with dm-verity. This optimization was later added in patch [2] which has shown improvement in performance benchmarks. ============================================== [1] Problem stacktrace [name:core&]BUG: sleeping function called from invalid context at kernel/locking/mutex.c:291 [name:core&]in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 1615, name: CpuMonitorServi [name:core&]preempt_count: 0, expected: 0 [name:core&]RCU nest depth: 1, expected: 0 CPU: 7 PID: 1615 Comm: CpuMonitorServi Tainted: G S W OE 6.1.25-android14-5-maybe-dirty-mainline #1 Hardware name: MT6897 (DT) Call trace: dump_backtrace+0x108/0x15c show_stack+0x20/0x30 dump_stack_lvl+0x6c/0x8c dump_stack+0x20/0x48 __might_resched+0x1fc/0x308 __might_sleep+0x50/0x88 mutex_lock+0x2c/0x110 z_erofs_decompress_queue+0x11c/0xc10 z_erofs_decompress_kickoff+0x110/0x1a4 z_erofs_decompressqueue_endio+0x154/0x180 bio_endio+0x1b0/0x1d8 __dm_io_complete+0x22c/0x280 clone_endio+0xe4/0x280 bio_endio+0x1b0/0x1d8 blk_update_request+0x138/0x3a4 blk_mq_plug_issue_direct+0xd4/0x19c blk_mq_flush_plug_list+0x2b0/0x354 __blk_flush_plug+0x110/0x160 blk_finish_plug+0x30/0x4c read_pages+0x2fc/0x370 page_cache_ra_unbounded+0xa4/0x23c page_cache_ra_order+0x290/0x320 do_sync_mmap_readahead+0x108/0x2c0 filemap_fault+0x19c/0x52c __do_fault+0xc4/0x114 handle_mm_fault+0x5b4/0x1168 do_page_fault+0x338/0x4b4 do_translation_fault+0x40/0x60 do_mem_abort+0x60/0xc8 el0_da+0x4c/0xe0 el0t_64_sync_handler+0xd4/0xfc el0t_64_sync+0x1a0/0x1a4 [2] Link: https://lore.kernel.org/all/20210317035448.13921-1-huangjianan@oppo.com/ The Linux kernel CVE team has assigned CVE-2023-53231 to this issue. Affected and fixed versions =========================== Fixed in 6.4.7 with commit 597fb60c75132719687e173b75cab8f6eb1ca657 Fixed in 6.5 with commit 12d0a24afd9ea58e581ea64d64e066f2027b28d9 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-53231 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: fs/erofs/zdata.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/597fb60c75132719687e173b75cab8f6eb1ca657 https://git.kernel.org/stable/c/12d0a24afd9ea58e581ea64d64e066f2027b28d9