lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 8 Jun 2022 13:40:49 +0200
From:   Pavel Machek <pavel@...x.de>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        Yuntao Wang <ytcoode@...il.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Sasha Levin <sashal@...nel.org>
Subject: Re: [PATCH 5.10 136/452] bpf: Fix excessive memory allocation in
 stack_map_alloc()

Hi!

> The 'n_buckets * (value_size + sizeof(struct stack_map_bucket))' part of the
> allocated memory for 'smap' is never used after the memlock accounting was
> removed, thus get rid of it.
> 
> [ Note, Daniel:
> 
> Commit b936ca643ade ("bpf: rework memlock-based memory accounting for maps")
> moved `cost += n_buckets * (value_size + sizeof(struct stack_map_bucket))`
> up and therefore before the bpf_map_area_alloc() allocation, sigh. In a later
> step commit c85d69135a91 ("bpf: move memory size checks to bpf_map_charge_init()"),
> and the overflow checks of `cost >= U32_MAX - PAGE_SIZE` moved into
> bpf_map_charge_init(). And then 370868107bf6 ("bpf: Eliminate rlimit-based
> memory accounting for stackmap maps") finally removed the bpf_map_charge_init().
> Anyway, the original code did the allocation same way as /after/ this fix. ]

We don't have 370868107bf6 in 5.10. Can someone verify this is still
right think to do for 5.10?

Best regards,
								Pavel
								
> +++ b/kernel/bpf/stackmap.c
> @@ -121,7 +121,6 @@ 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);
>  	if (err)
>  		return ERR_PTR(err);

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ