lkml.org 
[lkml]   [2021]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc
On Wed, Jan 27, 2021 at 11:23:41AM +0700, Bui Quang Minh wrote:
> > * Seems like there are quite a few similar calls scattered around
> > (cpumap, etc.). Did you audit these as well?
>
> I spotted another bug after re-auditting. In hashtab, there ares 2 places using
> the same calls
>
> static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
> {
> /* ... snip ... */
> if (htab->n_buckets == 0 ||
> htab->n_buckets > U32_MAX / sizeof(struct bucket))
> goto free_htab;
>
> htab->buckets = bpf_map_area_alloc(htab->n_buckets *
> sizeof(struct bucket),
> htab->map.numa_node);
> }
>
> This is safe because of the above check.
>
> static int prealloc_init(struct bpf_htab *htab)
> {
> u32 num_entries = htab->map.max_entries;
> htab->elems = bpf_map_area_alloc(htab->elem_size * num_entries,
> htab->map.numa_node);
> }
>
> This is not safe since there is no limit check in elem_size.

So sorry but I rechecked and saw this bug in hashtab has been fixed with commit
e1868b9e36d0ca

Thank you,
Quang Minh.

\
 
 \ /
  Last update: 2021-01-27 06:27    [W:0.217 / U:0.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site