X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=inline;f=lib%2Fbpf%2Fbpf_validate.c;h=09331258ebf6a109cd6335a36efd40a5a53fac76;hb=757f40e28e1c681054dcc1923b19c7fbeb7ae626;hp=7b1291b382e9cd9d591afaf7e387b0cd53ebc1b2;hpb=cdcee2ec9b81457f9059c3f3a007e69190672634;p=dpdk.git diff --git a/lib/bpf/bpf_validate.c b/lib/bpf/bpf_validate.c index 7b1291b382..09331258eb 100644 --- a/lib/bpf/bpf_validate.c +++ b/lib/bpf/bpf_validate.c @@ -661,8 +661,15 @@ eval_alu(struct bpf_verifier *bvf, const struct ebpf_insn *ins) op = BPF_OP(ins->code); + /* Allow self-xor as way to zero register */ + if (op == BPF_XOR && BPF_SRC(ins->code) == BPF_X && + ins->src_reg == ins->dst_reg) { + eval_fill_imm(&rs, UINT64_MAX, 0); + eval_fill_imm(rd, UINT64_MAX, 0); + } + err = eval_defined((op != EBPF_MOV) ? rd : NULL, - (op != BPF_NEG) ? &rs : NULL); + (op != BPF_NEG) ? &rs : NULL); if (err != NULL) return err; @@ -1723,7 +1730,7 @@ static const struct bpf_ins_check ins_chk[UINT8_MAX + 1] = { /* * make sure that instruction syntax is valid, - * and it fields don't violate partciular instrcution type restrictions. + * and its fields don't violate particular instruction type restrictions. */ static const char * check_syntax(const struct ebpf_insn *ins) @@ -1954,7 +1961,7 @@ log_loop(const struct bpf_verifier *bvf) * First pass goes though all instructions in the set, checks that each * instruction is a valid one (correct syntax, valid field values, etc.) * and constructs control flow graph (CFG). - * Then deapth-first search is performed over the constructed graph. + * Then depth-first search is performed over the constructed graph. * Programs with unreachable instructions and/or loops will be rejected. */ static int @@ -1981,7 +1988,7 @@ validate(struct bpf_verifier *bvf) /* * construct CFG, jcc nodes have to outgoing edges, - * 'exit' nodes - none, all others nodes have exaclty one + * 'exit' nodes - none, all other nodes have exactly one * outgoing edge. */ switch (ins->code) { @@ -2251,7 +2258,7 @@ evaluate(struct bpf_verifier *bvf) idx = get_node_idx(bvf, node); op = ins[idx].code; - /* for jcc node make a copy of evaluatoion state */ + /* for jcc node make a copy of evaluation state */ if (node->nb_edge > 1) rc |= save_eval_state(bvf, node);