On Tue, Sep 19, 2017 at 10:03:23PM -0700, Alexei Starovoitov via iovisor-dev 
wrote:
> On Mon, Sep 18, 2017 at 11:14 AM, Paul Chaignon
> <paul.chaig...@orange.com> wrote:
> >> > +                   BPF_ALU64_IMM(BPF_ADD, BPF_REG_2,
> >> > +                                 offsetof(struct test_val, foo)),
> >>
> >> there are few bugs here.
> >> 1. it adds 4 byte, so it should have been rejected as misaligned.
> >
> > I've fixed the other bugs, but I don't understand that one. Don't all
> > map helpers assume byte aligned pointers? Even without this patch, map
> > helper accesses to misaligned pointers are accepted if we first copy
> > the value on the stack.
> 
> that is a bit of grey territory unfortunately which we need to
> document and audit the verifier.
> Most map helpers don't take advantage of key/value alignment
> constraint, but pcpu maps, lpm maps already require
> both key and value to be aligned.
> Ex: bpf_long_memcpy() and trie_lookup_elem().

I've been fiddling around with these maps but I still don't fully
understand the misalignment issues. I'm interested in understanding
this further but I might not be the best person to address this if it's
needed anytime soon.
I'll send the last version of the patch with the additional tests in
the meantime. The two things probably need to be in separate patches
anyway?
_______________________________________________
iovisor-dev mailing list
iovisor-dev@lists.iovisor.org
https://lists.iovisor.org/mailman/listinfo/iovisor-dev

Reply via email to