public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: "Björn Töpel" <bjorn.topel@gmail.com>
Cc: netdev@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	"Björn Töpel" <bjorn.topel@intel.com>,
	bpf@vger.kernel.org, toke@redhat.com
Subject: Re: [PATCH bpf] bpf: change size to u64 for bpf_map_{area_alloc,charge_init}()
Date: Tue, 29 Oct 2019 09:12:10 -0700	[thread overview]
Message-ID: <20191029091210.0a7f0b37@cakuba.hsd1.ca.comcast.net> (raw)
In-Reply-To: <20191029154307.23053-1-bjorn.topel@gmail.com>

On Tue, 29 Oct 2019 16:43:07 +0100, Björn Töpel wrote:
> From: Björn Töpel <bjorn.topel@intel.com>
> 
> The functions bpf_map_area_alloc() and bpf_map_charge_init() prior
> this commit passed the size parameter as size_t. In this commit this
> is changed to u64.
> 
> All users of these functions avoid size_t overflows on 32-bit systems,
> by explicitly using u64 when calculating the allocation size and
> memory charge cost. However, since the result was narrowed by the
> size_t when passing size and cost to the functions, the overflow
> handling was in vain.
> 
> Instead of changing all call sites to size_t and handle overflow at
> the call site, the parameter is changed to u64 and checked in the
> functions above.
> 
> Fixes: d407bd25a204 ("bpf: don't trigger OOM killer under pressure with map alloc")
> Fixes: c85d69135a91 ("bpf: move memory size checks to bpf_map_charge_init()")
> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>

Okay, I guess that's the smallest change we can make here.

I'd prefer we went the way of using the standard overflow handling the
kernel has, rather than proliferating this u64 + U32_MAX comparison
stuff. But it's hard to argue with the patch length in light of the
necessary backports..

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>

  reply	other threads:[~2019-10-29 16:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-29 15:43 [PATCH bpf] bpf: change size to u64 for bpf_map_{area_alloc,charge_init}() Björn Töpel
2019-10-29 16:12 ` Jakub Kicinski [this message]
2019-10-29 16:16   ` Björn Töpel
2019-10-31 20:59 ` Daniel Borkmann

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=20191029091210.0a7f0b37@cakuba.hsd1.ca.comcast.net \
    --to=jakub.kicinski@netronome.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@gmail.com \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --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