diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index f3f14519708d..4a3333039bf2 100755 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -2169,8 +2169,12 @@ do_sim: /* 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