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] [day] [month] [year] [list]
Message-ID: <87ms39c2sl.fsf@linux.dev>
Date: Mon, 22 Dec 2025 19:09:14 -0800
From: Roman Gushchin <roman.gushchin@...ux.dev>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: bpf <bpf@...r.kernel.org>,  linux-mm <linux-mm@...ck.org>,  LKML
 <linux-kernel@...r.kernel.org>,  JP Kobryn <inwardvessel@...il.com>,
  Alexei Starovoitov <ast@...nel.org>,  Daniel Borkmann
 <daniel@...earbox.net>,  Shakeel Butt <shakeel.butt@...ux.dev>,  Michal
 Hocko <mhocko@...nel.org>,  Johannes Weiner <hannes@...xchg.org>
Subject: Re: [PATCH bpf-next v3 4/6] mm: introduce BPF kfuncs to access
 memcg statistics and events

Alexei Starovoitov <alexei.starovoitov@...il.com> writes:

> On Mon, Dec 22, 2025 at 12:18 PM Roman Gushchin
> <roman.gushchin@...ux.dev> wrote:
>>
>> +       if (idx < 0 || idx >= MEMCG_NR_STAT || !memcg_stat_item_valid(idx))
>> +               return (unsigned long)-1;
>
> memcg_stat_item_valid() and memcg_stat_item_valid()
> helpers introduced specifically to be used in these kfuncs,
> so I feel it's cleaner to do all idx checking within them
> instead of splitting the checks like this.
> Then it will be easier to see that
> memcg_stat_item_valid(idx) access is in bounds when idx < MEMCG_NR_STAT
>
> Also I'd do one check like (u32)idx >= MEMCG_NR_STAT
> and drop idx < 0 part. Compiler is probably smart enough to
> optimize this way itself, but I'd still do one check.

Sure, good point.
Thanks for reviews!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ