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]
Message-ID: <d4f8346d-42eb-48db-962d-6bc0fc348510@lucifer.local>
Date: Tue, 26 Aug 2025 15:21:28 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: David Hildenbrand <david@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
        Alexander Gordeev <agordeev@...ux.ibm.com>,
        Gerald Schaefer <gerald.schaefer@...ux.ibm.com>,
        Heiko Carstens <hca@...ux.ibm.com>, Vasily Gorbik <gor@...ux.ibm.com>,
        Christian Borntraeger <borntraeger@...ux.ibm.com>,
        Sven Schnelle <svens@...ux.ibm.com>,
        "David S . Miller" <davem@...emloft.net>,
        Andreas Larsson <andreas@...sler.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Andy Lutomirski <luto@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
        Borislav Petkov <bp@...en8.de>, "H . Peter Anvin" <hpa@...or.com>,
        Alexander Viro <viro@...iv.linux.org.uk>,
        Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
        Kees Cook <kees@...nel.org>, Zi Yan <ziy@...dia.com>,
        Baolin Wang <baolin.wang@...ux.alibaba.com>,
        "Liam R . Howlett" <Liam.Howlett@...cle.com>,
        Nico Pache <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
        Dev Jain <dev.jain@....com>, Barry Song <baohua@...nel.org>,
        Xu Xin <xu.xin16@....com.cn>,
        Chengming Zhou <chengming.zhou@...ux.dev>,
        Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
        Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>,
        David Rientjes <rientjes@...gle.com>,
        Shakeel Butt <shakeel.butt@...ux.dev>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Oleg Nesterov <oleg@...hat.com>, Juri Lelli <juri.lelli@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>,
        Mel Gorman <mgorman@...e.de>, Valentin Schneider <vschneid@...hat.com>,
        Jason Gunthorpe <jgg@...pe.ca>, John Hubbard <jhubbard@...dia.com>,
        Peter Xu <peterx@...hat.com>, Jann Horn <jannh@...gle.com>,
        Pedro Falcato <pfalcato@...e.de>, Matthew Wilcox <willy@...radead.org>,
        Mateusz Guzik <mjguzik@...il.com>, linux-s390@...r.kernel.org,
        linux-kernel@...r.kernel.org, sparclinux@...r.kernel.org,
        linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
        linux-trace-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org
Subject: Re: [PATCH 08/10] mm: update fork mm->flags initialisation to use
 bitmap

On Tue, Aug 26, 2025 at 03:12:08PM +0200, David Hildenbrand wrote:
> On 12.08.25 17:44, Lorenzo Stoakes wrote:
> > We now need to account for flag initialisation on fork. We retain the
> > existing logic as much as we can, but dub the existing flag mask legacy.
> >
> > These flags are therefore required to fit in the first 32-bits of the flags
> > field.
> >
> > However, further flag propagation upon fork can be implemented in mm_init()
> > on a per-flag basis.
> >
> > We ensure we clear the entire bitmap prior to setting it, and use
> > __mm_flags_get_word() and __mm_flags_set_word() to manipulate these legacy
> > fields efficiently.
> >
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
> > ---
> >   include/linux/mm_types.h | 13 ++++++++++---
> >   kernel/fork.c            |  7 +++++--
> >   2 files changed, 15 insertions(+), 5 deletions(-)
> >
> > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> > index 38b3fa927997..25577ab39094 100644
> > --- a/include/linux/mm_types.h
> > +++ b/include/linux/mm_types.h
> > @@ -1820,16 +1820,23 @@ enum {
> >   #define MMF_TOPDOWN		31	/* mm searches top down by default */
> >   #define MMF_TOPDOWN_MASK	_BITUL(MMF_TOPDOWN)
> > -#define MMF_INIT_MASK		(MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\
> > +#define MMF_INIT_LEGACY_MASK	(MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\
> >   				 MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK |\
> >   				 MMF_VM_MERGE_ANY_MASK | MMF_TOPDOWN_MASK)
> > -static inline unsigned long mmf_init_flags(unsigned long flags)
> > +/* Legacy flags must fit within 32 bits. */
> > +static_assert((u64)MMF_INIT_LEGACY_MASK <= (u64)UINT_MAX);
>
> Why not use the magic number 32 you are mentioning in the comment? :)

Meh I mean UINT_MAX works as a good 'any bit' mask and this will work on
both 32-bit and 64-bit systems.

>
> static_assert((u32)MMF_INIT_LEGACY_MASK != MMF_INIT_LEGACY_MASK);

On 32-bit that'd not work would it?

Kinda the point here is that the issue would get picked up on either.

I think with the comment above it's fine as-is! :)

>
> > +
> > +/*
> > + * Initialise legacy flags according to masks, propagating selected flags on
> > + * fork. Further flag manipulation can be performed by the caller.
>
> It's weird not reading "initialize", but I am afraid the kernel is already
> tainted :P
>
> t14s: ~/git/linux nth_page $ git grep "initialise" | wc -l
> 1778
> t14s: ~/git/linux nth_page $ git grep "initialize" | wc -l
> 22043

British English in the kernel will survive if I have anything to do with it
;)

>
> Besides the assert simplification
>
> Acked-by: David Hildenbrand <david@...hat.com>

Thanks!

>
> --
> Cheers
>
> David / dhildenb
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ