twtiger / gosecco

Go seccomp parser and compiler
GNU Lesser General Public License v3.0
53 stars 7 forks source link

Add other BPF_JMP comparison instructions #6

Closed chelseakomlo closed 8 years ago

chelseakomlo commented 8 years ago

Currently, we only have jump if equal to.

We should also add jump if greater/less than, greater than/equal to, etc.

olabini commented 8 years ago

I assume this is for the compiler. We should also keep in mind that we can't actually do LT and LTE in the bytecode - we have to switch the L and R or negate the result of the comparison.

chelseakomlo commented 8 years ago

Yes, that is what is there. (Just switched the JT and JF for these cases).

chelseakomlo commented 8 years ago

Oh, I see what you mean. Wouldn't switching the JT and JF also achieve the same thing though?

olabini commented 8 years ago

Well, to emulate a LT, you would have to use a GTE and switch JT and JF - did is only true because we are using unsigned numbers with no overflow though - there are edge cases otherwise.

chelseakomlo commented 8 years ago

Great. That is what I did.