Patch "bpf: prevent r10 register from being marked as precise" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bpf: prevent r10 register from being marked as precise

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bpf-prevent-r10-register-from-being-marked-as-precis.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1e0d726a089d6dad3642dc5661115280f216f0cb
Author: Andrii Nakryiko <andrii@xxxxxxxxxx>
Date:   Thu Apr 4 14:45:35 2024 -0700

    bpf: prevent r10 register from being marked as precise
    
    [ Upstream commit 1f2a74b41ea8b902687eb97c4e7e3f558801865b ]
    
    r10 is a special register that is not under BPF program's control and is
    always effectively precise. The rest of precision logic assumes that
    only r0-r9 SCALAR registers are marked as precise, so prevent r10 from
    being marked precise.
    
    This can happen due to signed cast instruction allowing to do something
    like `r0 = (s8)r10;`, which later, if r0 needs to be precise, would lead
    to an attempt to mark r10 as precise.
    
    Prevent this with an extra check during instruction backtracking.
    
    Fixes: 8100928c8814 ("bpf: Support new sign-extension mov insns")
    Reported-by: syzbot+148110ee7cf72f39f33e@xxxxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20240404214536.3551295-1-andrii@xxxxxxxxxx
    Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 11bc3af33f34f..68ec508057466 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -3584,7 +3584,8 @@ static int backtrack_insn(struct bpf_verifier_env *env, int idx, int subseq_idx,
 				 * sreg needs precision before this insn
 				 */
 				bt_clear_reg(bt, dreg);
-				bt_set_reg(bt, sreg);
+				if (sreg != BPF_REG_FP)
+					bt_set_reg(bt, sreg);
 			} else {
 				/* dreg = K
 				 * dreg needs precision after this insn.
@@ -3600,7 +3601,8 @@ static int backtrack_insn(struct bpf_verifier_env *env, int idx, int subseq_idx,
 				 * both dreg and sreg need precision
 				 * before this insn
 				 */
-				bt_set_reg(bt, sreg);
+				if (sreg != BPF_REG_FP)
+					bt_set_reg(bt, sreg);
 			} /* else dreg += K
 			   * dreg still needs precision before this insn
 			   */




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux