[PATCH v8 03/12] landlock: Replace union access_masks_all with helper functions

Günther Noack gnoack3000 at gmail.com
Mon Mar 30 19:00:31 UTC 2026


On Mon, Mar 30, 2026 at 12:53:21PM +0200, Mickaël Salaün wrote:
> On Mon, Mar 30, 2026 at 11:56:40AM +0200, Mickaël Salaün wrote:
> > On Fri, Mar 27, 2026 at 05:48:28PM +0100, Günther Noack wrote:
> > > * Stop using a union for access_masks_all.
> > > * Expose helper functions for intersection checks and union operations.
> > > 
> > > The memory layout of bitfields is only loosely defined by the C
> > > standard, so our static assertion that expects a fixed size was
> > > brittle, and it broke on some compilers when we attempted to add a
> > > 17th file system access right.
> > > 
> > > Reported-by: kernel test robot <lkp at intel.com>
> > > Closes: https://lore.kernel.org/oe-kbuild-all/202603261438.jBx2DGNe-lkp@intel.com/
> > > Signed-off-by: Günther Noack <gnoack3000 at gmail.com>
> > > ---
> > >  security/landlock/access.h  | 21 ++++++++++++++-------
> > >  security/landlock/cred.h    | 10 ++--------
> > >  security/landlock/ruleset.h | 13 ++++---------
> > >  3 files changed, 20 insertions(+), 24 deletions(-)
> > 
> > I'd prefer this approach:
> > 
> > diff --git a/security/landlock/access.h b/security/landlock/access.h
> > index 89dc8e7b93da..bc9efbb5c900 100644
> > --- a/security/landlock/access.h
> > +++ b/security/landlock/access.h
> > @@ -50,7 +50,7 @@ struct access_masks {
> >         access_mask_t fs : LANDLOCK_NUM_ACCESS_FS;
> >         access_mask_t net : LANDLOCK_NUM_ACCESS_NET;
> >         access_mask_t scope : LANDLOCK_NUM_SCOPE;
> > -};
> > +} __packed;
> 
> Actually, we can just use '__packed __aligned(sizeof(u32))' and avoid
> the static_assert change.  That would have no impact on x86, but pack it
> on m68k.

Thanks, good catch (and thanks for pushing it to mic-next).
Fingers crossed that this works on m68k.

–Günther



More information about the Linux-security-module-archive mailing list