From: Daniel Borkmann <dborkman@redhat.com>
To: Chema Gonzalez <chema@google.com>
Cc: David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Alexei Starovoitov <ast@plumgrid.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH v1 net-next] net: filter: fix length calculation in BPF testsuite
Date: Thu, 29 May 2014 22:41:28 +0200 [thread overview]
Message-ID: <53879B78.5050106@redhat.com> (raw)
In-Reply-To: <1401391757-27620-1-git-send-email-chema@google.com>
On 05/29/2014 09:29 PM, Chema Gonzalez wrote:
> The current probe_filter_length() (the function that calculates the
> length of a test BPF filter) behavior is to declare the end of the
> filter as soon as it finds {0, *, *, 0}. This is actually a valid
> insn ("ld #0"), so any filter with includes "BPF_STMT(BPF_LD | BPF_IMM, 0)"
> fails (its length is cut short).
>
> We are changing probe_filter_length() so as to start from the end, and
> declare the end of the filter as the first instruction which is not
> {0, *, *, 0}. This solution produces a simpler patch than the
> alternative of using an explicit end-of-filter mark. It is technically
> incorrect if your filter ends up with "ld #0", but that should not
> happen anyway.
>
> We also add a new test (LD_IMM_0) that includes ld #0 (does not work
> without this patch).
>
> Signed-off-by: Chema Gonzalez <chema@google.com>
Looks good to me, thanks a lot Chema!
Acked-by: Daniel Borkmann <dborkman@redhat.com>
> + for (len = MAX_INSNS-1; len > 0; --len)
> + if (fp[len].code != 0 || fp[len].k != 0)
> + break;
>
> - return len;
> + return len+1;
Nit: would be great to have a whitespace between MAX_INSNS-1 and len+1 but
that shouldn't matter that much, perhaps.
next prev parent reply other threads:[~2014-05-29 20:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 19:29 [PATCH v1 net-next] net: filter: fix length calculation in BPF testsuite Chema Gonzalez
2014-05-29 20:41 ` Daniel Borkmann [this message]
2014-05-30 17:15 ` Chema Gonzalez
2014-05-30 17:15 ` [PATCH v2 " Chema Gonzalez
2014-05-31 19:21 ` Daniel Borkmann
2014-06-02 6:33 ` Alexei Starovoitov
2014-06-02 23:33 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53879B78.5050106@redhat.com \
--to=dborkman@redhat.com \
--cc=ast@plumgrid.com \
--cc=chema@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.