From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: netdev@vger.kernel.org, jakub.kicinski@netronome.com,
"Michael S. Tsirkin" <mst@redhat.com>,
pavel.odintsov@gmail.com, Jason Wang <jasowang@redhat.com>,
mchan@broadcom.com, John Fastabend <john.fastabend@gmail.com>,
peter.waskiewicz.jr@intel.com,
Daniel Borkmann <borkmann@iogearbox.net>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Andy Gospodarek <andy@greyhouse.net>,
brouer@redhat.com
Subject: Re: [net-next V4 PATCH 1/5] bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP
Date: Fri, 6 Oct 2017 17:58:36 +0200 [thread overview]
Message-ID: <20171006175836.1d3d7a8a@redhat.com> (raw)
In-Reply-To: <59D798B8.8090101@iogearbox.net>
On Fri, 06 Oct 2017 16:52:40 +0200 Daniel Borkmann <daniel@iogearbox.net> wrote:
> On 10/06/2017 12:50 PM, Jesper Dangaard Brouer wrote:
> > On Thu, 05 Oct 2017 11:40:15 +0200
> > Daniel Borkmann <daniel@iogearbox.net> wrote:
> >> On 10/04/2017 02:03 PM, Jesper Dangaard Brouer wrote:
> >> [...]
> [...]
> >>> + /* Updating qsize cause re-allocation of bpf_cpu_map_entry */
> >>> + rcpu = __cpu_map_entry_alloc(qsize, key_cpu, map->id);
> >>> + if (!rcpu)
> >>> + return -ENOMEM;
> >>> + }
> >>> + rcu_read_lock();
> >>> + __cpu_map_entry_replace(cmap, key_cpu, rcpu);
> >>> + rcu_read_unlock();
> >>> + return 0;
> >>
> >> You need to update verifier such that this function cannot be called
> >> out of an BPF program,
> >
> > In the example BPF program, I do a lookup into the map, but only to
> > verify that an entry exist (I don't look at the value). I would like
> > to support such usage.
>
> Ok, put comment below.
>
> >> otherwise it would be possible under full RCU
> >> read context, which is explicitly avoided here and also it would otherwise
> >> be allowed for other maps of different type as well, which needs to
> >> be avoided.
> >
> > Sorry, I don't follow this.
>
> What I meant is that check_map_func_compatibility() should check for
> BPF_MAP_TYPE_CPUMAP and only allow func_id of BPF_FUNC_redirect_map
> and BPF_FUNC_map_lookup_elem to be used, which I haven't seen the set
> restricting it to. Some of your later patches do this for the helper
> BPF_FUNC_redirect_map but the important point is that map updates
> wouldn't be done out of the BPF program itself, but rather from user
> space control path given they can't be done under full RCU read lock
> context if I read this correctly (which the programs run in though).
Okay, I choose to restrict bpf_prog side in check_map_func_compatibility()
as you describe. And I changed the user program to keep track of valid
entries via secondary map. We can always add/allow lookup later if users
request this.
I'll send out V5 shortly...
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2017-10-06 15:58 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 12:03 [net-next V4 PATCH 0/5] New bpf cpumap type for XDP_REDIRECT Jesper Dangaard Brouer
2017-10-04 12:03 ` [net-next V4 PATCH 1/5] bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP Jesper Dangaard Brouer
2017-10-04 19:02 ` Alexei Starovoitov
2017-10-05 18:01 ` John Fastabend
2017-10-06 9:03 ` Jesper Dangaard Brouer
2017-10-05 9:40 ` Daniel Borkmann
2017-10-06 10:50 ` Jesper Dangaard Brouer
2017-10-06 14:52 ` Daniel Borkmann
2017-10-06 15:58 ` Jesper Dangaard Brouer [this message]
2017-10-25 16:53 ` [bpf] 3ea693a925: BUG:unable_to_handle_kernel kernel test robot
2017-10-25 16:59 ` Michael S. Tsirkin
2017-10-25 10:02 ` [LKP] " Ye Xiaolong
2017-10-25 12:09 ` Ye Xiaolong
2017-10-25 16:54 ` kernel test robot
2017-10-04 12:03 ` [net-next V4 PATCH 2/5] bpf: XDP_REDIRECT enable use of cpumap Jesper Dangaard Brouer
2017-10-05 10:10 ` Daniel Borkmann
2017-10-06 11:17 ` Jesper Dangaard Brouer
2017-10-06 12:01 ` Jesper Dangaard Brouer
2017-10-06 15:45 ` Jesper Dangaard Brouer
2017-10-06 8:30 ` kbuild test robot
2017-10-04 12:03 ` [net-next V4 PATCH 3/5] bpf: cpumap xdp_buff to skb conversion and allocation Jesper Dangaard Brouer
2017-10-05 10:22 ` Daniel Borkmann
2017-10-06 12:11 ` Jesper Dangaard Brouer
2017-10-04 12:04 ` [net-next V4 PATCH 4/5] bpf: cpumap add tracepoints Jesper Dangaard Brouer
2017-10-04 12:04 ` [net-next V4 PATCH 5/5] samples/bpf: add cpumap sample program xdp_redirect_cpu Jesper Dangaard Brouer
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=20171006175836.1d3d7a8a@redhat.com \
--to=brouer@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andy@greyhouse.net \
--cc=borkmann@iogearbox.net \
--cc=daniel@iogearbox.net \
--cc=jakub.kicinski@netronome.com \
--cc=jasowang@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=mchan@broadcom.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pavel.odintsov@gmail.com \
--cc=peter.waskiewicz.jr@intel.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).