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: <CACT4Y+YmWrEW9m5zxKoD-Hu0TXKWPVAr0_Xe_X9WGtZWH5W1_g@mail.gmail.com>
Date: Mon, 24 Feb 2025 14:25:32 +0100
From: Dmitry Vyukov <dvyukov@...gle.com>
To: Dave Hansen <dave.hansen@...el.com>
Cc: mathieu.desnoyers@...icios.com, peterz@...radead.org, boqun.feng@...il.com, 
	tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, 
	dave.hansen@...ux.intel.com, hpa@...or.com, aruna.ramakrishna@...cle.com, 
	elver@...gle.com, "Paul E. McKenney" <paulmck@...nel.org>, x86@...nel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/4] pkeys: add API to switch to permissive pkey register

On Fri, 21 Feb 2025 at 18:01, Dave Hansen <dave.hansen@...el.com> wrote:
>
> On 2/17/25 03:07, Dmitry Vyukov wrote:
> ...
> >  /*
> >   * If more than 16 keys are ever supported, a thorough audit
> >   * will be necessary to ensure that the types that store key
> > @@ -123,4 +125,16 @@ static inline int vma_pkey(struct vm_area_struct *vma)
> >       return (vma->vm_flags & vma_pkey_mask) >> VM_PKEY_SHIFT;
> >  }
> >
> > +typedef u32 pkey_reg_t;
> > +
> > +static inline pkey_reg_t switch_to_permissive_pkey_reg(void)
> > +{
> > +     return write_pkru(0);
> > +}
>
> Just a naming nit: the "switch_to" and "reg" parts of this don't quite
> parse for me. This is writing a _value_ to a register. Maybe:
>
>         write_permissive_pkey_val()
> or
>         set_permissive_pkey_val()
>
> would be a better name.

Changed them to write_permissive_pkey_val/write_pkey_val in v4.

> > diff --git a/include/linux/pkeys.h b/include/linux/pkeys.h
> > index 86be8bf27b41b..d94a0ae7a784b 100644
> > --- a/include/linux/pkeys.h
> > +++ b/include/linux/pkeys.h
> > @@ -48,4 +48,26 @@ static inline bool arch_pkeys_enabled(void)
> >
> >  #endif /* ! CONFIG_ARCH_HAS_PKEYS */
> >
> > +#ifndef CONFIG_ARCH_HAS_PERMISSIVE_PKEY
> > +
> > +/*
> > + * Common name for value of the register that controls access to PKEYs
> > + * (called differently on different arches: PKRU, POR, AMR).
> > + */
> > +typedef int pkey_reg_t;
> Tiny nit: Should this be an unsigned type?
>
> Nobody should be manipulating it, but I'd be surprised if any of the
> architectures have a signed type for it.

Since this is a stub type, can matching the real types do any good
besides masking programming errors?
I've changed it to char in v4 to surface more potential programming errors.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ