netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: ast@kernel.org
Cc: netdev@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>,
	Song Liu <songliubraving@fb.com>
Subject: [PATCH bpf 4/7] bpf: fix cg_skb types to hint access type in may_access_direct_pkt_data
Date: Wed, 24 Oct 2018 22:05:46 +0200	[thread overview]
Message-ID: <20181024200549.8516-5-daniel@iogearbox.net> (raw)
In-Reply-To: <20181024200549.8516-1-daniel@iogearbox.net>

Commit b39b5f411dcf ("bpf: add cg_skb_is_valid_access for
BPF_PROG_TYPE_CGROUP_SKB") added direct packet access for skbs in
cg_skb program types, however allowed access type was not added to
the may_access_direct_pkt_data() helper. Therefore the latter always
returns false. This is not directly an issue, it just means writes
are unconditionally disabled (which is correct) but also reads.
Latter is relevant in this function when BPF helpers may read direct
packet data which is unconditionally disabled then. Fix it by properly
adding BPF_PROG_TYPE_CGROUP_SKB to may_access_direct_pkt_data().

Fixes: b39b5f411dcf ("bpf: add cg_skb_is_valid_access for BPF_PROG_TYPE_CGROUP_SKB")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
---
 kernel/bpf/verifier.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index b0cc8f2..5fc9a65 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1393,6 +1393,7 @@ static bool may_access_direct_pkt_data(struct bpf_verifier_env *env,
 	case BPF_PROG_TYPE_LWT_SEG6LOCAL:
 	case BPF_PROG_TYPE_SK_REUSEPORT:
 	case BPF_PROG_TYPE_FLOW_DISSECTOR:
+	case BPF_PROG_TYPE_CGROUP_SKB:
 		if (t == BPF_WRITE)
 			return false;
 		/* fallthrough */
-- 
2.9.5

  parent reply	other threads:[~2018-10-25  4:35 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 ` Daniel Borkmann [this message]
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
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=20181024200549.8516-5-daniel@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=ast@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    /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 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).