Daniel Borkmann c502faf941 bpf, lpm: fix overflows in trie_alloc checks
Cap the maximum (total) value size and bail out if larger than KMALLOC_MAX_SIZE
as otherwise it doesn't make any sense to proceed further, since we're
guaranteed to fail to allocate elements anyway in lpm_trie_node_alloc();
likleyhood of failure is still high for large values, though, similarly
as with htab case in non-prealloc.

Next, make sure that cost vars are really u64 instead of size_t, so that we
don't overflow on 32 bit and charge only tiny map.pages against memlock while
allowing huge max_entries; cap also the max cost like we do with other map
types.

Fixes: b95a5c4db09b ("bpf: add a longest prefix match trie map implementation")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-08 14:40:03 -05:00
..
2016-12-25 17:21:22 +01:00
2015-11-19 17:51:48 +01:00
2017-01-12 07:01:56 -07:00
2016-12-25 17:21:22 +01:00
2015-11-23 09:44:58 +01:00
2016-12-12 18:55:06 -08:00
2016-02-16 13:04:58 -05:00
2017-01-24 16:26:14 -08:00
2016-05-27 15:26:11 -07:00
2016-03-01 20:36:56 +01:00
2016-12-22 22:58:37 -05:00
2017-01-24 06:23:51 +13:00
2016-09-22 20:00:36 -05:00