diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 031d2c44db4a35f68eb092846fec3b90f7451173..364b9760d1a73b02ff81074a62ee5a16becdaf02 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -5802,8 +5802,12 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, /* If we're in commit phase, we're done here given we already * pushed the truncated dst_reg into the speculative verification * stack. + * + * Also, when register is a known constant, we rewrite register-based + * operation to immediate-based, and thus do not need masking (and as + * a consequence, do not need to simulate the zero-truncation either). */ - if (commit_window) + if (commit_window || off_is_imm) return 0; /* Simulate and find potential out-of-bounds access under