All of lore.kernel.org
 help / color / mirror / Atom feed
From: Song Liu <liu.song.a23@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@kernel.org>, Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf 7/7] bpf: make direct packet write unclone more robust
Date: Wed, 24 Oct 2018 14:42:14 -0700	[thread overview]
Message-ID: <CAPhsuW4V46Hi=q_fSma3mgji_JQxhjjpa1hPEtEGjE_WvEamhg@mail.gmail.com> (raw)
In-Reply-To: <20181024200549.8516-8-daniel@iogearbox.net>

On Wed, Oct 24, 2018 at 1:06 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> Given this seems to be quite fragile and can easily slip through the
> cracks, lets make direct packet write more robust by requiring that
> future program types which allow for such write must provide a prologue
> callback. In case of XDP and sk_msg it's noop, thus add a generic noop
> handler there. The latter starts out with NULL data/data_end unconditionally
> when sg pages are shared.
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
> ---
>  kernel/bpf/verifier.c |  6 +++++-
>  net/core/filter.c     | 11 +++++++++++
>  2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 5fc9a65..171a2c8 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -5709,7 +5709,11 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env)
>         bool is_narrower_load;
>         u32 target_size;
>
> -       if (ops->gen_prologue) {
> +       if (ops->gen_prologue || env->seen_direct_write) {
> +               if (!ops->gen_prologue) {
> +                       verbose(env, "bpf verifier is misconfigured\n");
> +                       return -EINVAL;
> +               }

nit: how about this?

diff --git i/kernel/bpf/verifier.c w/kernel/bpf/verifier.c
index 6fbe7a8afed7..d35078024e35 100644
--- i/kernel/bpf/verifier.c
+++ w/kernel/bpf/verifier.c
@@ -5286,6 +5286,11 @@ static int convert_ctx_accesses(struct
bpf_verifier_env *env)
        bool is_narrower_load;
        u32 target_size;

+       if (!ops->gen_prologue && env->seen_direct_write) {
+               verbose(env, "bpf verifier is misconfigured\n");
+               return -EINVAL;
+       }
+
        if (ops->gen_prologue) {
                cnt = ops->gen_prologue(insn_buf, env->seen_direct_write,
                                        env->prog);

  reply	other threads:[~2018-10-25  6:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-24 20:05 [PATCH bpf 0/7] Batch of direct packet access fixes for BPF Daniel Borkmann
2018-10-24 20:05 ` [PATCH bpf 1/7] bpf: fix test suite to enable all unpriv program types Daniel Borkmann
2018-10-24 20:05 ` [PATCH bpf 2/7] bpf: disallow direct packet access for unpriv in cg_skb Daniel Borkmann
2018-10-24 20:05 ` [PATCH bpf 3/7] bpf: fix direct packet access for flow dissector progs Daniel Borkmann
2018-10-24 20:05 ` [PATCH bpf 4/7] bpf: fix cg_skb types to hint access type in may_access_direct_pkt_data Daniel Borkmann
2018-10-24 20:05 ` [PATCH bpf 5/7] bpf: fix direct packet write into pop/peek helpers Daniel Borkmann
2018-10-24 22:30   ` Mauricio Vasquez
2018-10-24 20:05 ` [PATCH bpf 6/7] bpf: fix leaking uninitialized memory on " Daniel Borkmann
2018-10-24 22:08   ` Mauricio Vasquez
2018-10-24 20:05 ` [PATCH bpf 7/7] bpf: make direct packet write unclone more robust Daniel Borkmann
2018-10-24 21:42   ` Song Liu [this message]
2018-10-24 22:08     ` Daniel Borkmann
2018-10-24 23:36       ` Song Liu
2018-10-24 21:43 ` [PATCH bpf 0/7] Batch of direct packet access fixes for BPF Song Liu
2018-10-26  0:11 ` Alexei Starovoitov

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='CAPhsuW4V46Hi=q_fSma3mgji_JQxhjjpa1hPEtEGjE_WvEamhg@mail.gmail.com' \
    --to=liu.song.a23@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --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.