Re: [PATCH] mm/pkey: Add PKEY_UNRESTRICTED macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 22/10/2024 14:01, Yury Khrustalev wrote:
> Memory protection keys (pkeys) uapi previously used two macros:

Nit: I would remove "previously" as it's not clear what it means here.

>  - PKEY_DISABLE_ACCESS 0x1
>  - PKEY_DISABLE_WRITE  0x2
>
> with implicit literal value of 0x0 that means "unrestricted". Code that
> works with pkeys has to use this literal value when implying that a pkey
> imposes no restrictions. This may reduce readability because 0 can be
> written in various ways (e.g. 0x0 or 0) and also because 0 in the context
> of pkeys can be mistaken for "no permissions" (akin PROT_NONE) while it
> actually means "no restrictions". This is important because pkeys are
> oftentimes used near mprotect() that uses PROT_ macros.
>
> This patch adds PKEY_UNRESTRICTED macro defined as 0x0.

Your Signed-off-by is missing.

With that fixed:

Reviewed-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>

- Kevin

> ---
> Applies to 42f7652d3eb5 (tag: v6.12-rc4).
>
> For context, this change will also allow for more consistent update of the
> Glibc manual [1] which in turn will help with introducing memory protection
> keys on AArch64 targets [2].
>
> [1] https://inbox.sourceware.org/libc-alpha/20241022073837.151355-1-yury.khrustalev@xxxxxxx/
> [2] https://inbox.sourceware.org/libc-alpha/20241011153614.3189334-1-yury.khrustalev@xxxxxxx/
>
> Is this patch OK?
>
> Kind regards,
> Yury
>
> ---
>  include/uapi/asm-generic/mman-common.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h
> index 6ce1f1ceb432..ea40e27e6dea 100644
> --- a/include/uapi/asm-generic/mman-common.h
> +++ b/include/uapi/asm-generic/mman-common.h
> @@ -82,6 +82,7 @@
>  /* compatibility flags */
>  #define MAP_FILE	0
>  
> +#define PKEY_UNRESTRICTED	0x0
>  #define PKEY_DISABLE_ACCESS	0x1
>  #define PKEY_DISABLE_WRITE	0x2
>  #define PKEY_ACCESS_MASK	(PKEY_DISABLE_ACCESS |\





[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux