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 ECF55266584 for ; Tue, 23 Sep 2025 06:01: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=1758607314; cv=none; b=F5f8R40eKSE8f9hljqkKtD7JDvzWwiN6RgZKpft54V2LnKAE8w/TA9ylJAOKgCTErcSAzaDrQF/BFyDaa9DpDgK/Yc/mtEKp/RNWwvg1+0N8WFdA5U8sb1Q1ZRFLGXvcX4ygiQl5jt0Iv2W/Dx7U1KysaEii2uNVMteGZgRxiss= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758607314; c=relaxed/simple; bh=ZUNt4VOW4NOOfN2EhO8PESoYRd82kHPYTYvnu3ZVu70=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sLEog9wo7P6WuGXfQMEOANsdO8PPlHeJNXyYJv5hpam091xrUlzO80NyIziWWen/R7o1npgDybJrFlOfMXY4s7GcrOm2NNb3lCm8U1Amnp5u8ajcPHqZjd6atv8f5UjnfrzpT4wSwnHY3MVepnUupvsybSbCeVjIGhEDMHgyKgI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tcrU3iOm; 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="tcrU3iOm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83695C4CEF5; Tue, 23 Sep 2025 06:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1758607313; bh=ZUNt4VOW4NOOfN2EhO8PESoYRd82kHPYTYvnu3ZVu70=; h=From:To:Cc:Subject:Date:Reply-to:From; b=tcrU3iOm8m/88h2vPl+t7g427WnF26MXyY3+X/xdVk3V6yevsmzfIUqH0Z5VOkwQu f6YaAQWJDZiLQqETpwybWTxILSOaVlzIXfg3jsK71PXbC1JW94BsLSM4Rl3N4pIy4I VjfHlxNHj7Ka5AztLahZkmal1HnPtI6qZdDMAasg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-39886: bpf: Tell memcg to use allow_spinning=false path in bpf_timer_init() Date: Tue, 23 Sep 2025 08:01:17 +0200 Message-ID: <2025092302-CVE-2025-39886-4bea@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=4494; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=L2IdZU9K5kKqHq/TsT6ZnBYfA2PM5kVL7fU1ev5SDKc=; b=owGbwMvMwCRo6H6F97bub03G02pJDBmXzOedvnqubPenVbmn9v+8/+nhLeO9pbq1K+peq7fbd ASmCi7R7IhlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJhN9lmGefdP/KudjsyVsX Odb3rdkf/Clbt55hfnr/hrjLsQbS8w2Ue7gzGcMKojNvAAA= 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: bpf: Tell memcg to use allow_spinning=false path in bpf_timer_init() Currently, calling bpf_map_kmalloc_node() from __bpf_async_init() can cause various locking issues; see the following stack trace (edited for style) as one example: ... [10.011566] do_raw_spin_lock.cold [10.011570] try_to_wake_up (5) double-acquiring the same [10.011575] kick_pool rq_lock, causing a hardlockup [10.011579] __queue_work [10.011582] queue_work_on [10.011585] kernfs_notify [10.011589] cgroup_file_notify [10.011593] try_charge_memcg (4) memcg accounting raises an [10.011597] obj_cgroup_charge_pages MEMCG_MAX event [10.011599] obj_cgroup_charge_account [10.011600] __memcg_slab_post_alloc_hook [10.011603] __kmalloc_node_noprof ... [10.011611] bpf_map_kmalloc_node [10.011612] __bpf_async_init [10.011615] bpf_timer_init (3) BPF calls bpf_timer_init() [10.011617] bpf_prog_xxxxxxxxxxxxxxxx_fcg_runnable [10.011619] bpf__sched_ext_ops_runnable [10.011620] enqueue_task_scx (2) BPF runs with rq_lock held [10.011622] enqueue_task [10.011626] ttwu_do_activate [10.011629] sched_ttwu_pending (1) grabs rq_lock ... The above was reproduced on bpf-next (b338cf849ec8) by modifying ./tools/sched_ext/scx_flatcg.bpf.c to call bpf_timer_init() during ops.runnable(), and hacking the memcg accounting code a bit to make a bpf_timer_init() call more likely to raise an MEMCG_MAX event. We have also run into other similar variants (both internally and on bpf-next), including double-acquiring cgroup_file_kn_lock, the same worker_pool::lock, etc. As suggested by Shakeel, fix this by using __GFP_HIGH instead of GFP_ATOMIC in __bpf_async_init(), so that e.g. if try_charge_memcg() raises an MEMCG_MAX event, we call __memcg_memory_event() with @allow_spinning=false and avoid calling cgroup_file_notify() there. Depends on mm patch "memcg: skip cgroup_file_notify if spinning is not allowed": https://lore.kernel.org/bpf/20250905201606.66198-1-shakeel.butt@linux.dev/ v0 approach s/bpf_map_kmalloc_node/bpf_mem_alloc/ https://lore.kernel.org/bpf/20250905061919.439648-1-yepeilin@google.com/ v1 approach: https://lore.kernel.org/bpf/20250905234547.862249-1-yepeilin@google.com/ The Linux kernel CVE team has assigned CVE-2025-39886 to this issue. Affected and fixed versions =========================== Issue introduced in 5.15 with commit b00628b1c7d595ae5b544e059c27b1f5828314b4 and fixed in 6.6.107 with commit 449682e76f32601f211816d3e2100bed87e67a4c Issue introduced in 5.15 with commit b00628b1c7d595ae5b544e059c27b1f5828314b4 and fixed in 6.12.48 with commit cd1fd26bb13473c1734e3026b2b97025a0a4087b Issue introduced in 5.15 with commit b00628b1c7d595ae5b544e059c27b1f5828314b4 and fixed in 6.16.8 with commit ac70cd446f83ccb25532b343919ab86eacdcd06a Issue introduced in 5.15 with commit b00628b1c7d595ae5b544e059c27b1f5828314b4 and fixed in 6.17-rc6 with commit 6d78b4473cdb08b74662355a9e8510bde09c511e 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-39886 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/bpf/helpers.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/449682e76f32601f211816d3e2100bed87e67a4c https://git.kernel.org/stable/c/cd1fd26bb13473c1734e3026b2b97025a0a4087b https://git.kernel.org/stable/c/ac70cd446f83ccb25532b343919ab86eacdcd06a https://git.kernel.org/stable/c/6d78b4473cdb08b74662355a9e8510bde09c511e