[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+FuTSfinkPAJKDZ9BmY_dLo60mdVFJ=B7xc4CN+SUwShoxFxg@mail.gmail.com>
Date: Fri, 14 Aug 2015 14:47:35 -0400
From: Willem de Bruijn <willemb@...gle.com>
To: Alexei Starovoitov <ast@...mgrid.com>
Cc: Network Development <netdev@...r.kernel.org>,
David Miller <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Daniel Borkmann <dborkman@...hat.com>
Subject: Re: [PATCH net-next 2/4] packet: add eBPF fanout mode
On Fri, Aug 14, 2015 at 1:03 PM, Alexei Starovoitov <ast@...mgrid.com> wrote:
> On 8/14/15 8:50 AM, Willem de Bruijn wrote:
>>
>> +static int fanout_set_data_ebpf(struct packet_fanout *f, char __user
>> *data,
>> + unsigned int len)
>> +{
>> + struct bpf_prog *new;
>> + u32 fd;
>> +
>> + if (len != sizeof(fd))
>> + return -EINVAL;
>> + if (copy_from_user(&fd, data, len))
>> + return -EFAULT;
>> +
>> + new = bpf_prog_get(fd);
>> + if (IS_ERR(new))
>> + return PTR_ERR(new);
>> +
>> + __fanout_set_data_bpf(f, new);
>> + return 0;
>> +}
>
>
> all looks great except in the above the check:
> if (new->type != BPF_PROG_TYPE_SOCKET_FILTER) {
> bpf_prog_put(new);
> return -EINVAL;
> }
> is missing. Otherwise user will be able to attach programs
> of wrong types to fanout.
Ai, good point!
> Also instead of:
> #define PACKET_FANOUT_BPF 6
> #define PACKET_FANOUT_EBPF 7
>
> I would call them FANOUT_CBPF and FANOUT_EBPF to be unambiguous.
> This is how bpf manpage distinguishes them.
>
Sounds good. I'll make both changes in v2. Thanks for reviewing, Alexei.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists