Re: [PATCH 2/2] fs: require FMODE_WRITE for F_SET_RW_HINT

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

 



On Fri 22-11-24 13:29:25, Christoph Hellwig wrote:
> F_SET_RW_HINT controls the placement of written file data.  A read-only
> fd should not allow for that.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Here I'm not so sure. Firstly, since you are an owner this doesn't add any
additional practical restriction. Secondly, you are not changing anything
on disk, just IO hints in memory... Thirdly, we generally don't require
writeable fd even to do file attribute changes (like with fchmod, fchown,
etc.).  So although the check makes some sense, it seems to be mostly
inconsistent with how we treat similar stuff.

								Honza
> ---
>  fs/fcntl.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/fcntl.c b/fs/fcntl.c
> index 7fc6190da342..12f60c42743a 100644
> --- a/fs/fcntl.c
> +++ b/fs/fcntl.c
> @@ -377,6 +377,8 @@ static long fcntl_set_rw_hint(struct file *file, unsigned int cmd,
>  
>  	if (!inode_owner_or_capable(file_mnt_idmap(file), inode))
>  		return -EPERM;
> +	if (!(file->f_mode & FMODE_WRITE))
> +		return -EBADF;
>  
>  	if (copy_from_user(&hint, argp, sizeof(hint)))
>  		return -EFAULT;
> -- 
> 2.45.2
> 
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux