[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210127050937.GA5418@ubuntu>
Date: Wed, 27 Jan 2021 12:09:37 +0700
From: Bui Quang Minh <minhquangbui99@...il.com>
To: Lorenz Bauer <lmb@...udflare.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, hawk@...nel.org,
John Fastabend <john.fastabend@...il.com>,
Andrii Nakryiko <andrii@...nel.org>, Martin Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
kpsingh@...nel.org, Jakub Sitnicki <jakub@...udflare.com>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [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.
Powered by blists - more mailing lists