On Mon, 09 Oct 2017 15:31:21 +0200
Daniel Borkmann <[email protected]> wrote:
> On 10/06/2017 06:12 PM, Jesper Dangaard Brouer wrote:
> [...]
> > +static struct bpf_map *cpu_map_alloc(union bpf_attr *attr)
> > +{
> > + struct bpf_cpu_map *cmap;
> > + int err = -ENOMEM;
>
> err init here is basically not needed since overriden later anyway
> w/o being read, but ...
Thank you for catching this! Guess, I'll send a V6 tomorrow.
[...]
> > + /* Notice returns -EPERM on if map size is larger than memlock limit */
> > + err = bpf_map_precharge_memlock(cmap->map.pages);
> > + if (err)
> > + goto free_cmap;
>
> ... here, you need to set err = -ENOMEM.
Yes, I see my mistake of assigning "err" here.
[...]
> > +static void *cpu_map_lookup_elem(struct bpf_map *map, void *key)
> > +{
> > + struct bpf_cpu_map_entry *rcpu =
> > + __cpu_map_lookup_elem(map, *(u32 *)key);
> > +
> > + return rcpu ? &rcpu->qsize : NULL;
>
> I still think from my prior email/comment that we should use per-cpu
> scratch buffer here. Would be nice to keep the guarantee that noone
> can modify it, it's just a tiny change.
Well, it's no-longer really needed, right(?), as this patchset update,
change that bpf-side cannot invoke this. The userspace-side reading
this will get a copy.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer