netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, davem@davemloft.net,
	ast@kernel.org, brouer@redhat.com, toke@redhat.com,
	lorenzo.bianconi@redhat.com, dsahern@kernel.org,
	andrii.nakryiko@gmail.com
Subject: Re: [PATCH v5 bpf-next 5/9] bpf: cpumap: add the possibility to attach an eBPF program to cpumap
Date: Sat, 4 Jul 2020 00:24:16 +0200	[thread overview]
Message-ID: <4dcc1530-ffdf-30a5-9806-0b06cd0f12d6@iogearbox.net> (raw)
In-Reply-To: <20200703204810.GB1321275@localhost.localdomain>

On 7/3/20 10:48 PM, Lorenzo Bianconi wrote:
>> On 6/30/20 2:49 PM, Lorenzo Bianconi wrote:
>> [...]
> 
> [...]
> 
>>>    	old_rcpu = xchg(&cmap->cpu_map[key_cpu], rcpu);
>>>    	if (old_rcpu) {
>>> +		if (old_rcpu->prog)
>>> +			bpf_prog_put(old_rcpu->prog);
>>>    		call_rcu(&old_rcpu->rcu, __cpu_map_entry_free);
>>>    		INIT_WORK(&old_rcpu->kthread_stop_wq, cpu_map_kthread_stop);
>>>    		schedule_work(&old_rcpu->kthread_stop_wq);
>>
>> Hm, not quite sure I follow the logic here. Why is the bpf_prog_put() not placed inside
>> __cpu_map_entry_free(), for example? Wouldn't this at least leave a potential small race
>> window of UAF given the rest is still live? If we already piggy-back from RCU side on
>> rcpu entry, why not having it in __cpu_map_entry_free()?
> 
> ack right, thanks for spotting this issue. I guess we can even move
> "bpf_prog_put(rcpu->prog)" in put_cpu_map_entry() so the last consumer
> of bpf_cpu_map_entry will free the attached program. Agree?

Yes, that sounds reasonable to me.

Thanks,
Daniel

  reply	other threads:[~2020-07-03 22:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 12:49 [PATCH v5 bpf-next 0/9] introduce support for XDP programs in CPUMAP Lorenzo Bianconi
2020-06-30 12:49 ` [PATCH v5 bpf-next 1/9] cpumap: use non-locked version __ptr_ring_consume_batched Lorenzo Bianconi
2020-06-30 12:49 ` [PATCH v5 bpf-next 2/9] net: refactor xdp_convert_buff_to_frame Lorenzo Bianconi
2020-06-30 12:49 ` [PATCH v5 bpf-next 3/9] samples/bpf: xdp_redirect_cpu_user: do not update bpf maps in option loop Lorenzo Bianconi
2020-06-30 12:49 ` [PATCH v5 bpf-next 4/9] cpumap: formalize map value as a named struct Lorenzo Bianconi
2020-06-30 12:49 ` [PATCH v5 bpf-next 5/9] bpf: cpumap: add the possibility to attach an eBPF program to cpumap Lorenzo Bianconi
2020-07-01 23:02   ` Daniel Borkmann
2020-07-03 15:46     ` Lorenzo Bianconi
2020-07-01 23:39   ` Daniel Borkmann
2020-07-03 20:48     ` Lorenzo Bianconi
2020-07-03 22:24       ` Daniel Borkmann [this message]
2020-06-30 12:49 ` [PATCH v5 bpf-next 6/9] bpf: cpumap: implement XDP_REDIRECT for eBPF programs attached to map entries Lorenzo Bianconi
2020-06-30 12:49 ` [PATCH v5 bpf-next 7/9] libbpf: add SEC name for xdp programs attached to CPUMAP Lorenzo Bianconi
2020-06-30 12:49 ` [PATCH v5 bpf-next 8/9] samples/bpf: xdp_redirect_cpu: load a eBPF program on cpumap Lorenzo Bianconi
2020-06-30 12:49 ` [PATCH v5 bpf-next 9/9] selftest: add tests for XDP programs in CPUMAP entries Lorenzo Bianconi

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=4dcc1530-ffdf-30a5-9806-0b06cd0f12d6@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.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).