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: <fs6mvtx5tla556t4bo4cex6i2pf4huvdzbfwymtckqh6ughd3h@yjjpeyko3kng>
Date: Tue, 25 Nov 2025 10:42:37 +0000
From: Pedro Falcato <pfalcato@...e.de>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, 
	Muchun Song <muchun.song@...ux.dev>, Oscar Salvador <osalvador@...e.de>, 
	David Hildenbrand <david@...hat.com>, "Liam R . Howlett" <Liam.Howlett@...cle.com>, 
	Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>, 
	Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>, 
	Axel Rasmussen <axelrasmussen@...gle.com>, Yuanchu Xie <yuanchu@...gle.com>, Wei Xu <weixugc@...gle.com>, 
	Peter Xu <peterx@...hat.com>, Ingo Molnar <mingo@...hat.com>, 
	Peter Zijlstra <peterz@...radead.org>, 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>, Kees Cook <kees@...nel.org>, 
	Matthew Wilcox <willy@...radead.org>, Jason Gunthorpe <jgg@...pe.ca>, 
	John Hubbard <jhubbard@...dia.com>, Leon Romanovsky <leon@...nel.org>, Zi Yan <ziy@...dia.com>, 
	Baolin Wang <baolin.wang@...ux.alibaba.com>, Nico Pache <npache@...hat.com>, 
	Ryan Roberts <ryan.roberts@....com>, Dev Jain <dev.jain@....com>, Barry Song <baohua@...nel.org>, 
	Lance Yang <lance.yang@...ux.dev>, Xu Xin <xu.xin16@....com.cn>, 
	Chengming Zhou <chengming.zhou@...ux.dev>, Jann Horn <jannh@...gle.com>, 
	Matthew Brost <matthew.brost@...el.com>, Joshua Hahn <joshua.hahnjy@...il.com>, 
	Rakie Kim <rakie.kim@...com>, Byungchul Park <byungchul@...com>, 
	Gregory Price <gourry@...rry.net>, Ying Huang <ying.huang@...ux.alibaba.com>, 
	Alistair Popple <apopple@...dia.com>, Shakeel Butt <shakeel.butt@...ux.dev>, 
	David Rientjes <rientjes@...gle.com>, Rik van Riel <riel@...riel.com>, 
	Harry Yoo <harry.yoo@...cle.com>, Kemeng Shi <shikemeng@...weicloud.com>, 
	Kairui Song <kasong@...cent.com>, Nhat Pham <nphamcs@...il.com>, Baoquan He <bhe@...hat.com>, 
	Chris Li <chrisl@...nel.org>, Johannes Weiner <hannes@...xchg.org>, 
	Qi Zheng <zhengqi.arch@...edance.com>, linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org, 
	linux-mm@...ck.org, Miguel Ojeda <ojeda@...nel.org>, 
	Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, 
	Bjorn Roy Baron <bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>, 
	Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, 
	Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>, 
	rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v3 1/4] mm: declare VMA flags by bit

On Tue, Nov 25, 2025 at 10:00:59AM +0000, Lorenzo Stoakes wrote:
> In order to lay the groundwork for VMA flags being a bitmap rather than a
> system word in size, we need to be able to consistently refer to VMA flags
> by bit number rather than value.
> 
> Take this opportunity to do so in an enum which we which is additionally
> useful for tooling to extract metadata from.
> 
> This additionally makes it very clear which bits are being used for what at
> a glance.
> 
> We use the VMA_ prefix for the bit values as it is logical to do so since
> these reference VMAs. We consistently suffix with _BIT to make it clear
> what the values refer to.
> 
> We declare bit values even when the flags that use them would not be
> enabled by config options as this is simply clearer and clearly defines
> what bit numbers are used for what, at no additional cost.
> 
> We declare a sparse-bitwise type vma_flag_t which ensures that users can't
> pass around invalid VMA flags by accident and prepares for future work
> towards VMA flags being a bitmap where we want to ensure bit values are
> type safe.
> 
> To make life easier, we declare some macro helpers - DECLARE_VMA_BIT()
> allows us to avoid duplication in the enum bit number declarations (and
> maintaining the sparse __bitwise attribute), and INIT_VM_FLAG() is used to
> assist with declaration of flags.
> 
> Unfortunately we can't declare both in the enum, as we run into issue with
> logic in the kernel requiring that flags are preprocessor definitions, and
> additionally we cannot have a macro which declares another macro so we must
> define each flag macro directly.
> 
> Additionally, update the VMA userland testing vma_internal.h header to
> include these changes.
> 
> We also have to fix the parameters to the vma_flag_*_atomic() functions
> since VMA_MAYBE_GUARD_BIT is now of type vma_flag_t and sparse will
> complain otherwise.
> 
> We have to update some rather silly if-deffery found in mm/task_mmu.c which
> would otherwise break.
> 
> Finally, we update the rust binding helper as now it cannot auto-detect the
> flags at all.
> 
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
> Acked-by: Vlastimil Babka <vbabka@...e.cz>

Reviewed-by: Pedro Falcato <pfalcato@...e.de>

Scary but cromulent-looking. Thanks :)

--
Pedro

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ