Sfoglia il codice sorgente

src/verifier.rs: Fix checks for divisions by zero

There is a bug in the verifier: The checks for divisions by zero when
the operand comes from an immediate are applied to 64-bit
multiplications instead of 64-mod operations. Fix it.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Quentin Monnet 2 anni fa
parent
commit
5fae4ece90
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      src/verifier.rs

+ 2 - 2
src/verifier.rs

@@ -185,7 +185,7 @@ pub fn check(prog: &[u8]) -> Result<(), Error> {
             ebpf::ADD64_REG  => {},
             ebpf::SUB64_IMM  => {},
             ebpf::SUB64_REG  => {},
-            ebpf::MUL64_IMM  => { check_imm_nonzero(&insn, insn_ptr)?; },
+            ebpf::MUL64_IMM  => {},
             ebpf::MUL64_REG  => {},
             ebpf::DIV64_IMM  => { check_imm_nonzero(&insn, insn_ptr)?; },
             ebpf::DIV64_REG  => {},
@@ -198,7 +198,7 @@ pub fn check(prog: &[u8]) -> Result<(), Error> {
             ebpf::RSH64_IMM  => {},
             ebpf::RSH64_REG  => {},
             ebpf::NEG64      => {},
-            ebpf::MOD64_IMM  => {},
+            ebpf::MOD64_IMM  => { check_imm_nonzero(&insn, insn_ptr)?; },
             ebpf::MOD64_REG  => {},
             ebpf::XOR64_IMM  => {},
             ebpf::XOR64_REG  => {},