bpf: Fix integer overflow in queue_stack_map_alloc.
Subsystems (3)
PATCH 1/1 bpf: Fix integer overflow in queue_stack_map_alloc.
Integer overflow in queue_stack_map_alloc when calculating size may lead to heap overflow of arbitrary length. The patch fix it by checking whether attr->max_entries+1 < attr->max_entries and bailing out if it is the case. The vulnerability is discovered with the assistance of syzkaller.
Reported-by Wei Wu <[email protected]>
To: Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc netdev <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Greg KH <[email protected]>
Signed-off-by Wei Wu <[email protected]>
--- kernel/bpf/queue_stack_maps.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/bpf/queue_stack_maps.c +2 -0
@@ -67,6 +67,8 @@ static struct bpf_map *queue_stack_map_alloc(union bpf_attr *attr)u64 queue_size, cost; size = attr->max_entries +1 ; +if (size < attr->max_entries) +return ERR_PTR (-EINVAL ); value_size = attr->value_size; queue_size =sizeof (*qs) + (u64 ) value_size * size;
Signature · 1 line
2.17.1