From: Yonghong Song <yhs@fb.com>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"Alexei Starovoitov" <ast@fb.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Subject: Re: [PATCH bpf] xdp: Prevent overflow in devmap_hash cost calculation for 32-bit builds
Date: Fri, 18 Oct 2019 16:44:00 +0000 [thread overview]
Message-ID: <bad3785d-e4d9-82e7-c5ef-f70e44616711@fb.com> (raw)
In-Reply-To: <20191017105702.2807093-1-toke@redhat.com>
On 10/17/19 3:57 AM, Toke Høiland-Jørgensen wrote:
> Tetsuo pointed out that without an explicit cast, the cost calculation for
> devmap_hash type maps could overflow on 32-bit builds. This adds the
> missing cast.
>
> Fixes: 6f9d451ab1a3 ("xdp: Add devmap_hash map type for looking up devices by hashed index")
> Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: Yonghong Song <yhs@fb.com>
> ---
> kernel/bpf/devmap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index a0a1153da5ae..e34fac6022eb 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -128,7 +128,7 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
>
> if (!dtab->n_buckets) /* Overflow check */
> return -EINVAL;
> - cost += sizeof(struct hlist_head) * dtab->n_buckets;
> + cost += (u64) sizeof(struct hlist_head) * dtab->n_buckets;
> }
>
> /* if map size is larger than memlock limit, reject it */
>
next prev parent reply other threads:[~2019-10-18 16:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-17 10:57 [PATCH bpf] xdp: Prevent overflow in devmap_hash cost calculation for 32-bit builds Toke Høiland-Jørgensen
2019-10-17 18:52 ` Jakub Kicinski
2019-10-18 9:15 ` Toke Høiland-Jørgensen
2019-10-18 17:19 ` Jakub Kicinski
2019-10-18 16:44 ` Yonghong Song [this message]
2019-10-18 23:25 ` Alexei Starovoitov
2019-10-18 23:31 ` Jakub Kicinski
2019-10-19 0:44 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bad3785d-e4d9-82e7-c5ef-f70e44616711@fb.com \
--to=yhs@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=toke@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).