Re: [PATCH 1/2] fcntl: add fcntl(F_CHECK_ORIGINAL_MEMFD)

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

 



On Thu, Aug 31, 2023 at 10:36:46PM +0200, Michal Clapinski wrote:
> Add a way to check if an fd points to the memfd's original open fd
> (the one created by memfd_create).
> Useful because only the original open fd can be both writable and
> executable.
> 
> Signed-off-by: Michal Clapinski <mclapinski@xxxxxxxxxx>
> ---
>  fs/fcntl.c                 | 3 +++
>  include/uapi/linux/fcntl.h | 9 +++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/fs/fcntl.c b/fs/fcntl.c
> index e871009f6c88..301527e07a4d 100644
> --- a/fs/fcntl.c
> +++ b/fs/fcntl.c
> @@ -419,6 +419,9 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
>  	case F_SET_RW_HINT:
>  		err = fcntl_rw_hint(filp, cmd, arg);
>  		break;
> +	case F_CHECK_ORIGINAL_MEMFD:
> +		err = !(filp->f_mode & FMODE_WRITER);
> +		break;

Honestly, make this an ioctl on memfds. This is so specific that it
really doesn't belong into fcntl().



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux