lkml.org 
[lkml]   [2022]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] bpf: Fix excessive memory allocation in stack_map_alloc()
Date
On Wed, 8 Jun 2022 17:20:58 +0200, Greg KH wrote:
> On Wed, Jun 08, 2022 at 10:25:38PM +0800, Yuntao Wang wrote:
> > The 'n_buckets * (value_size + sizeof(struct stack_map_bucket))' part of
> > the allocated memory for 'smap' is never used, get rid of it.
> >
> > Fixes: b936ca643ade ("bpf: rework memlock-based memory accounting for maps")
> > Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
> > Link: https://lore.kernel.org/bpf/20220407130423.798386-1-ytcoode@gmail.com
> > ---
> > This is the modified version for 5.10, the original patch is:
> >
> > [ Upstream commit b45043192b3e481304062938a6561da2ceea46a6 ]
> >
> > It would be better if the new patch can be reviewed by someone else.
>
> What is wrong with the version that we have queued up in the 5.10-stable
> review queue right now?

Since the 5.10 branch doesn't have commit 370868107bf6, the upstream version
is not correct for it, I modified the original patch and wanted to backport
it to the 5.10 branch.

> >
> > kernel/bpf/stackmap.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
> > index 4575d2d60cb1..54fdcb78ad19 100644
> > --- a/kernel/bpf/stackmap.c
> > +++ b/kernel/bpf/stackmap.c
> > @@ -121,8 +121,8 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
> > return ERR_PTR(-E2BIG);
> >
> > cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap);
> > - cost += n_buckets * (value_size + sizeof(struct stack_map_bucket));
> > - err = bpf_map_charge_init(&mem, cost);
> > + err = bpf_map_charge_init(&mem, cost + n_buckets *
> > + (value_size + sizeof(struct stack_map_bucket)));
>
> This differs from what we have queued up for 5.4.y and 5.10.y, why?
> If you are going to modify the upstream version, you need to document in
> great detail what you have changed and why you have changed it.
>
> thanks,
>
> greg k-h

\
 
 \ /
  Last update: 2022-06-08 18:12    [W:0.502 / U:1.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site