Re: [PATCH bpf-next v2] bpf: check flags in 'bpf_ringbuf_discard()' and 'bpf_ringbuf_submit()'

From
Alexei Starovoitov <hidden>
Date
2021-03-30 23:17:32
Also in
bpf, lkml
Reply to
Pedro Tammela, 2021-03-30
On Tue, Mar 30, 2021 at 3:54 PM Pedro Tammela [off-list ref] wrote:
quoted hunk ↗ jump to hunk

 BPF_CALL_2(bpf_ringbuf_submit, void *, sample, u64, flags)
 {
+       if (unlikely(flags & ~(BPF_RB_NO_WAKEUP | BPF_RB_FORCE_WAKEUP)))
+               return -EINVAL;
+
        bpf_ringbuf_commit(sample, flags, false /* discard */);
+
        return 0;
I think ringbuf design was meant for bpf_ringbuf_submit to never fail.
If we do flag validation it probably should be done at the verifier time.
Thread (6 messages) 6 messages, 4 authors, last reply 2021-04-03
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help