bpf, ringbuf: Deny reserve of buffers larger than ringbuf
[linux-2.6-microblaze.git] / kernel / bpf / ringbuf.c
index f25b719..b86d80c 100644 (file)
@@ -315,6 +315,9 @@ static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size)
                return NULL;
 
        len = round_up(size + BPF_RINGBUF_HDR_SZ, 8);
+       if (len > rb->mask + 1)
+               return NULL;
+
        cons_pos = smp_load_acquire(&rb->consumer_pos);
 
        if (in_nmi()) {