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 B544E131E49 for ; Tue, 23 Sep 2025 06:01:14 +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=1758607274; cv=none; b=ChKKLnY1cL/RxFiWGTgjkZSVgDg3TsPzPtmVNYZVPX7IdR/KehFELlMJt7BDxoMER5Az/iM4tZ1cPywtRnm4adNeyGmSY1rDBsmVfJGOJU3ZFKsT2ThshfVUHwHBkFV51YglrDI2BRCNSY3lFY2AvacNE/wQ1LRcOWglsFJCj1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758607274; c=relaxed/simple; bh=Gf86kRkJGT46OZe+cRoY94u5gPj4WLNKHONBDNBvXI4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=metwFJ6Jk1h9qvWoz9mysWYmMC3XQ9ldx18qrWXqEUP5u5y4kvU5MTWD9KWd9/0owTW8cD1r0PH4aoEKDtZ1RCOaTagFFPmb9eUvZSnb6MRBZSpXEqR7c6ppjwS5z5iEqQo7yxpdY99WWF5tw1G+/t7vvuwpzFzkl5BZAKx1lys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=e5DJfXeS; 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="e5DJfXeS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8458C4CEF5; Tue, 23 Sep 2025 06:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1758607274; bh=Gf86kRkJGT46OZe+cRoY94u5gPj4WLNKHONBDNBvXI4=; h=From:To:Cc:Subject:Date:Reply-to:From; b=e5DJfXeSWm4fwbTvNidKTIOqW4L0kQ4GkinseM9vNTmsVz7IJIxhYDUk0I2x7lhuN GlH1N3oN14Y5nXJM7SO/dh3+jM7awMLof1iuZTWiwHCB/SWKVOcVaXnrT4wi4pxPDH osS2XBbR1Y+bGeWg7f7J5vbsWDPDskqmd9FtM5G4= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-39877: mm/damon/sysfs: fix use-after-free in state_show() Date: Tue, 23 Sep 2025 08:01:08 +0200 Message-ID: <2025092301-CVE-2025-39877-1244@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=3379; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=61b+v98OYBBtZUn6hM0YNkH1f4gyCU2+iqCjqZGFp4M=; b=owGbwMvMwCRo6H6F97bub03G02pJDBmXzOd6rzE07/+67WmyaSbrtIW8yXerZzWJ/Ypcs/f/z TWlu0NiOmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiTB4Mc2U3fs0U83ZRd5yn kiyjECwrpvu/imF+xbn8yXbMpzM47kULbfeR8vfeWfcLAA== 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/damon/sysfs: fix use-after-free in state_show() state_show() reads kdamond->damon_ctx without holding damon_sysfs_lock. This allows a use-after-free race: CPU 0 CPU 1 ----- ----- state_show() damon_sysfs_turn_damon_on() ctx = kdamond->damon_ctx; mutex_lock(&damon_sysfs_lock); damon_destroy_ctx(kdamond->damon_ctx); kdamond->damon_ctx = NULL; mutex_unlock(&damon_sysfs_lock); damon_is_running(ctx); /* ctx is freed */ mutex_lock(&ctx->kdamond_lock); /* UAF */ (The race can also occur with damon_sysfs_kdamonds_rm_dirs() and damon_sysfs_kdamond_release(), which free or replace the context under damon_sysfs_lock.) Fix by taking damon_sysfs_lock before dereferencing the context, mirroring the locking used in pid_show(). The bug has existed since state_show() first accessed kdamond->damon_ctx. The Linux kernel CVE team has assigned CVE-2025-39877 to this issue. Affected and fixed versions =========================== Issue introduced in 5.18 with commit a61ea561c87139992fe32afdee48a6f6b85d824a and fixed in 6.1.153 with commit 3858c44341ad49dc7544b19cc9f9ecffaa7cc50e Issue introduced in 5.18 with commit a61ea561c87139992fe32afdee48a6f6b85d824a and fixed in 6.6.107 with commit 60d7a3d2b985a395318faa1d88da6915fad11c19 Issue introduced in 5.18 with commit a61ea561c87139992fe32afdee48a6f6b85d824a and fixed in 6.12.48 with commit 26d29b2ac87a2989071755f9828ebf839b560d4c Issue introduced in 5.18 with commit a61ea561c87139992fe32afdee48a6f6b85d824a and fixed in 6.16.8 with commit 4e87f461d61959647464a94d11ae15c011be58ce Issue introduced in 5.18 with commit a61ea561c87139992fe32afdee48a6f6b85d824a and fixed in 6.17-rc6 with commit 3260a3f0828e06f5f13fac69fb1999a6d60d9cff 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-2025-39877 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/damon/sysfs.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/3858c44341ad49dc7544b19cc9f9ecffaa7cc50e https://git.kernel.org/stable/c/60d7a3d2b985a395318faa1d88da6915fad11c19 https://git.kernel.org/stable/c/26d29b2ac87a2989071755f9828ebf839b560d4c https://git.kernel.org/stable/c/4e87f461d61959647464a94d11ae15c011be58ce https://git.kernel.org/stable/c/3260a3f0828e06f5f13fac69fb1999a6d60d9cff