For the English version of this alert, click here.
Allele Security Alert
ASA-2018-00053
Identificador(es)
ASA-2018-00053
Título
Integer overflow em queue_stack_map_alloc()
Fabricante(s)
Linux foundation
Produto(s)
Linux
Versão(ões) afetada(s)
Linux 4.20-rc1
Versão(ões) corrigida(s)
Linux 4.20-rc5
Prova de conceito
Sim
Descrição
Existe um integer overflow na função queue_stack_map_alloc() que pode ser conduzido posteriormente para um buffer overflow no kernel do Linux versão 4.20-rc. A exploração desta vulnerabilidade pode conduzir a escalação de privilégios.
Detalhes técnicos
No código a seguir mostra um integer overflow quando calcula-se size = attr->max_entries + 1; size é usado para calcular queue_size na linha 72 e e queue_size é usado na função malloc(), se attr->max_entries é 0xffffffff, então size será zero, que resulta em um menor buffer alocado.
File: kernel/bpf/queue_stack_maps.c --- static struct bpf_map *queue_stack_map_alloc(union bpf_attr *attr) 63 { 64 int ret, numa_node = bpf_map_attr_numa_node(attr); 65 struct bpf_queue_stack *qs; 66 u32 size, value_size; 67 u64 queue_size, cost; 68 69 size = attr->max_entries + 1; 70 value_size = attr->value_size; 71 72 queue_size = sizeof(*qs) + (u64) value_size * size; 73 74 cost = queue_size; 75 if (cost >= U32_MAX - PAGE_SIZE) 76 return ERR_PTR(-E2BIG); 77 78 cost = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT; 79 80 ret = bpf_map_precharge_memlock(cost); 81 if (ret < 0) 82 return ERR_PTR(ret); 83 84 qs = bpf_map_area_alloc(queue_size, numa_node); ... ---
Posteriormente na função queue_stack_map_push_elem() é possível causar um overflow no buffer com comprimento arbitrário com conteúdo controlado pelo usuário.
File: kernel/bpf/queue_stack_maps.c
---
...
229 dst = &qs->elements[qs->head * qs->map.value_size];
230 memcpy(dst, value, qs->map.value_size);
...
---
Créditos
Wei Wu
Referência(s)
[PATCH bpf] bpf: Fix integer overflow in queue_stack_map_alloc.
https://marc.info/?l=linux-netdev&m=154290236228315&w=2
fwd: [vs-plain] Kernel heap overflow in bpf leading to LPE (exploit provided)
https://seclists.org/oss-sec/2018/q4/170
[PATCH bpf] bpf: fix integer overflow in queue_stack_map
https://marc.info/?l=linux-netdev&m=154291261031288&w=2
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=69500127424cd90ff2cf8191256b2ac3b0a4af56
Se encontrou algum erro neste alerta ou deseja uma análise compreensiva, entre em contato.
Última modificação: 31 janeiro 2019