netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] Two cls_bpf fixes
@ 2015-01-22  9:41 Daniel Borkmann
  2015-01-22  9:41 ` [PATCH net 1/2] net: cls_bpf: fix size mismatch on filter preparation Daniel Borkmann
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Daniel Borkmann @ 2015-01-22  9:41 UTC (permalink / raw)
  To: davem; +Cc: jiri, netdev

Found them while doing a review on act_bpf and going over the
cls_bpf code again. Will also address the first issue in act_bpf
as it needs to be fixed there, too.

Thanks!

Daniel Borkmann (2):
  net: cls_bpf: fix size mismatch on filter preparation
  net: cls_bpf: fix auto generation of per list handles

 net/sched/cls_bpf.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] net: cls_bpf: fix size mismatch on filter preparation
@ 2015-01-22 16:39 Alexei Starovoitov
  0 siblings, 0 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2015-01-22 16:39 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: David S. Miller, Jiří Pírko,
	netdev@vger.kernel.org

On Thu, Jan 22, 2015 at 1:41 AM, Daniel Borkmann <dborkman@redhat.com> wrote:
> In cls_bpf_modify_existing(), we read out the number of filter blocks,
> do some sanity checks, allocate a block on that size, and copy over the
> BPF instruction blob from user space, then pass everything through the
> classic BPF checker prior to installation of the classifier.
>
> We should reject mismatches here, there are 2 scenarios: the number of
> filter blocks could be smaller than the provided instruction blob, so
> we do a partial copy of the BPF program, and thus the instructions will
> either be rejected from the verifier or a valid BPF program will be run;
> in the other case, we'll end up copying more than we're supposed to,
> and most likely the trailing garbage will be rejected by the verifier
> as well (i.e. we need to fit instruction pattern, ret {A,K} needs to be
> last instruction, load/stores must be correct, etc); in case not, we
> would leak memory when dumping back instruction patterns. The code should
> have only used nla_len() as Dave noted to avoid this from the beginning.
> Anyway, lets fix it by rejecting such load attempts.
>
> Fixes: 7d1d65cb84e1 ("net: sched: cls_bpf: add BPF-based classifier")
> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
> Acked-by: Jiri Pirko <jiri@resnulli.us>

Acked-by: Alexei Starovoitov <ast@plumgrid.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-27  0:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-22  9:41 [PATCH net 0/2] Two cls_bpf fixes Daniel Borkmann
2015-01-22  9:41 ` [PATCH net 1/2] net: cls_bpf: fix size mismatch on filter preparation Daniel Borkmann
2015-01-22  9:41 ` [PATCH net 2/2] net: cls_bpf: fix auto generation of per list handles Daniel Borkmann
2015-01-22 18:52   ` Alexei Starovoitov
2015-01-22 19:02     ` Daniel Borkmann
2015-01-26 23:50 ` [PATCH net 0/2] Two cls_bpf fixes David Miller
  -- strict thread matches above, loose matches on Subject: below --
2015-01-22 16:39 [PATCH net 1/2] net: cls_bpf: fix size mismatch on filter preparation Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).