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 2E8C72820B7 for ; Wed, 18 Jun 2025 09:36:43 +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=1750239403; cv=none; b=lb8qrjDDZMZNvyOFTyyV3xVGT3xByPPBUi2u/4cYz1MCe7zxUUBjZtImcUPqLJ5VD0oeNkWksTn7Z/Y9AZjrUIwHr2J9ozMG2bpfogPoWAvZc9bLPZijae9faD2ly+CEkgM1dpt+rnqbZz+c3OHbBEx6OapuyZ7h24edGDKySEI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750239403; c=relaxed/simple; bh=ZrVhaboa3NqRHgBZpH6JmR1Ga+NeEm+DdHe93d3cT6o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Eszs/I0kZnawrDA2RDlF44eezcKTfNz1wVdIZSlh1iKsQxVb5nQq7YQgtwcSDLayNR1wdz673hzt1OisjvMpyDOM1pNoosP/95C2cAgngcDjjhBvKtABkx1VWzgN9lhnhPq6AHNstip07d8xTbVFuU1IZRADy+RY8DrS4UyA6WE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=r90wxg5d; 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="r90wxg5d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B52EC4CEE7; Wed, 18 Jun 2025 09:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750239403; bh=ZrVhaboa3NqRHgBZpH6JmR1Ga+NeEm+DdHe93d3cT6o=; h=From:To:Cc:Subject:Date:Reply-to:From; b=r90wxg5d4vE1UU1xuCSaHma7iRNy8DzpsF5Gs7RMxwkv+WE94XexlJ2koOVznHOhO EjwkD43SX2gVMCBgBtlQYbY4D2/zo4TQ1nsbhbPDe1ibTL6zPXioGeiofouzupoUWP XAzWmc2BlnBQlblaEUpnFbBz2d2JjVl6L8a8sJpI= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-38060: bpf: copy_verifier_state() should copy 'loop_entry' field Date: Wed, 18 Jun 2025 11:33:55 +0200 Message-ID: <2025061834-CVE-2025-38060-2363@gregkh> X-Mailer: git-send-email 2.49.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=6114; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=bcsvKY/BhIpRmup37bxiVEEtTifhiKgyWB1DbUJTsFU=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlB7e9XvLJqYDIN9p0iLMsUtin+hoaVgVd9v3xvItOby G/HguI7YlkYBJkYZMUUWb5s4zm6v+KQopeh7WmYOaxMIEMYuDgFYCITNzMsuBY725JVoa/zDtda CYtNnn8exTm1MMyv+mrsbaWS1cYj8syoiPdu8oKJMhwA 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: copy_verifier_state() should copy 'loop_entry' field The bpf_verifier_state.loop_entry state should be copied by copy_verifier_state(). Otherwise, .loop_entry values from unrelated states would poison env->cur_state. Additionally, env->stack should not contain any states with .loop_entry != NULL. The states in env->stack are yet to be verified, while .loop_entry is set for states that reached an equivalent state. This means that env->cur_state->loop_entry should always be NULL after pop_stack(). See the selftest in the next commit for an example of the program that is not safe yet is accepted by verifier w/o this fix. This change has some verification performance impact for selftests: File Program Insns (A) Insns (B) Insns (DIFF) States (A) States (B) States (DIFF) ---------------------------------- ---------------------------- --------- --------- -------------- ---------- ---------- ------------- arena_htab.bpf.o arena_htab_llvm 717 426 -291 (-40.59%) 57 37 -20 (-35.09%) arena_htab_asm.bpf.o arena_htab_asm 597 445 -152 (-25.46%) 47 37 -10 (-21.28%) arena_list.bpf.o arena_list_del 309 279 -30 (-9.71%) 23 14 -9 (-39.13%) iters.bpf.o iter_subprog_check_stacksafe 155 141 -14 (-9.03%) 15 14 -1 (-6.67%) iters.bpf.o iter_subprog_iters 1094 1003 -91 (-8.32%) 88 83 -5 (-5.68%) iters.bpf.o loop_state_deps2 479 725 +246 (+51.36%) 46 63 +17 (+36.96%) kmem_cache_iter.bpf.o open_coded_iter 63 59 -4 (-6.35%) 7 6 -1 (-14.29%) verifier_bits_iter.bpf.o max_words 92 84 -8 (-8.70%) 8 7 -1 (-12.50%) verifier_iterating_callbacks.bpf.o cond_break2 113 107 -6 (-5.31%) 12 12 +0 (+0.00%) And significant negative impact for sched_ext: File Program Insns (A) Insns (B) Insns (DIFF) States (A) States (B) States (DIFF) ----------------- ---------------------- --------- --------- -------------------- ---------- ---------- ------------------ bpf.bpf.o lavd_init 7039 14723 +7684 (+109.16%) 490 1139 +649 (+132.45%) bpf.bpf.o layered_dispatch 11485 10548 -937 (-8.16%) 848 762 -86 (-10.14%) bpf.bpf.o layered_dump 7422 1000001 +992579 (+13373.47%) 681 31178 +30497 (+4478.27%) bpf.bpf.o layered_enqueue 16854 71127 +54273 (+322.02%) 1611 6450 +4839 (+300.37%) bpf.bpf.o p2dq_dispatch 665 791 +126 (+18.95%) 68 78 +10 (+14.71%) bpf.bpf.o p2dq_init 2343 2980 +637 (+27.19%) 201 237 +36 (+17.91%) bpf.bpf.o refresh_layer_cpumasks 16487 674760 +658273 (+3992.68%) 1770 65370 +63600 (+3593.22%) bpf.bpf.o rusty_select_cpu 1937 40872 +38935 (+2010.07%) 177 3210 +3033 (+1713.56%) scx_central.bpf.o central_dispatch 636 2687 +2051 (+322.48%) 63 227 +164 (+260.32%) scx_nest.bpf.o nest_init 636 815 +179 (+28.14%) 60 73 +13 (+21.67%) scx_qmap.bpf.o qmap_dispatch 2393 3580 +1187 (+49.60%) 196 253 +57 (+29.08%) scx_qmap.bpf.o qmap_dump 233 318 +85 (+36.48%) 22 30 +8 (+36.36%) scx_qmap.bpf.o qmap_init 16367 17436 +1069 (+6.53%) 603 669 +66 (+10.95%) Note 'layered_dump' program, which now hits 1M instructions limit. This impact would be mitigated in the next patch. The Linux kernel CVE team has assigned CVE-2025-38060 to this issue. Affected and fixed versions =========================== Fixed in 6.12.31 with commit 46ba5757a7a4714e7d3f68cfe118208822cb3d78 Fixed in 6.14.9 with commit 8b4afd89fa75f738a80ca849126fd3cad77bcbf1 Fixed in 6.15 with commit bbbc02b7445ebfda13e4847f4f1413c6480a85a9 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-38060 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/verifier.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/46ba5757a7a4714e7d3f68cfe118208822cb3d78 https://git.kernel.org/stable/c/8b4afd89fa75f738a80ca849126fd3cad77bcbf1 https://git.kernel.org/stable/c/bbbc02b7445ebfda13e4847f4f1413c6480a85a9