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: <177f4c8a-1ac7-4fee-bb34-ebecc4ba9384@redhat.com>
Date: Mon, 1 Sep 2025 15:23:22 +0200
From: David Hildenbrand <david@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
 Joey Pabalinas <joeypabalinas@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
 Baolin Wang <baolin.wang@...ux.alibaba.com>, Hugh Dickins <hughd@...gle.com>
Subject: Re: [PATCH] mm/memfd: remove redundant casts

On 31.08.25 21:34, Andrew Morton wrote:
> On Sun, 31 Aug 2025 01:47:48 -1000 Joey Pabalinas <joeypabalinas@...il.com> wrote:
> 
>> MFD_ALL_FLAGS is already an unsigned int. Remove redundant casts to
>> unsigned int.
> 
> lgtm.
> 
> It's rather annoying that the MFD_ALL_FLAGS definition is so far away
> from the other MFD_* definitions.  What do peope think of this little
> cleanup?
> 
> From: Andrew Morton <akpm@...ux-foundation.org>
> Subject: memfd: move MFD_ALL_FLAGS definition to memfd.h
> Date: Sun Aug 31 12:29:57 PM PDT 2025
> 
> It's not part of the UAPI, but putting it here is better from a
> maintainability POV.
> 
> Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
> ---
> 
>   include/uapi/linux/memfd.h |    2 ++
>   mm/memfd.c                 |    2 --
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> --- a/mm/memfd.c~memfd-move-mfd_all_flags-definition-to-memfdh
> +++ a/mm/memfd.c
> @@ -313,8 +313,6 @@ long memfd_fcntl(struct file *file, unsi
>   #define MFD_NAME_PREFIX_LEN (sizeof(MFD_NAME_PREFIX) - 1)
>   #define MFD_NAME_MAX_LEN (NAME_MAX - MFD_NAME_PREFIX_LEN)
>   
> -#define MFD_ALL_FLAGS (MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_HUGETLB | MFD_NOEXEC_SEAL | MFD_EXEC)
> -
>   static int check_sysctl_memfd_noexec(unsigned int *flags)
>   {
>   #ifdef CONFIG_SYSCTL
> --- a/include/uapi/linux/memfd.h~memfd-move-mfd_all_flags-definition-to-memfdh
> +++ a/include/uapi/linux/memfd.h
> @@ -12,6 +12,8 @@
>   #define MFD_NOEXEC_SEAL		0x0008U
>   /* executable */
>   #define MFD_EXEC		0x0010U
> +#define MFD_ALL_FLAGS		(MFD_CLOEXEC | MFD_ALLOW_SEALING | \
> +				 MFD_HUGETLB | MFD_NOEXEC_SEAL | MFD_EXEC)

No strong opinion.

When we are exposing this through uapi, wondering if we should rename it 
to something else that includes "MASK".

Quickly search for similar instances. For mmap we have the internal 
"LEGACY_MAP_MASK", but that's also a bit different.

There is this oddity that we store the hugetlb size in the upper bits of 
flags, masked by (MFD_HUGE_MASK << MFD_HUGE_SHIFT).

MFD_FLAGS_MASK maybe? not sure.

-- 
Cheers

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ