Re: [PATCH 01/18] vfs: introduce new file range exchange ioctl

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

 



On Thu, Apr 01, 2021 at 01:44:10AM +0000, Al Viro wrote:
> On Wed, Mar 31, 2021 at 06:08:52PM -0700, Darrick J. Wong wrote:
> 
> > +	ret = vfs_xchg_file_range(file1.file, file2, &args);
> > +	if (ret)
> > +		goto fdput;
> > +
> > +	/*
> > +	 * The VFS will set RANGE_FSYNC on its own if the file or inode require
> > +	 * synchronous writes.  Don't leak this back to userspace.
> > +	 */
> > +	args.flags &= ~FILE_XCHG_RANGE_FSYNC;
> > +	args.flags |= (old_flags & FILE_XCHG_RANGE_FSYNC);
> > +
> > +	if (copy_to_user(argp, &args, sizeof(args)))
> > +		ret = -EFAULT;
> 
> Erm...  How is userland supposed to figure out whether that EFAULT
> came before or after the operation?  Which of the fields are outputs,
> anyway?

Come to think of it, none of the fields are outputs, so this whole block
can go away.  Thanks for noticing that. :)

> > +	/* Don't touch certain kinds of inodes */
> > +	if (IS_IMMUTABLE(inode1) || IS_IMMUTABLE(inode2))
> > +		return -EPERM;
> 
> Append-only should get the same treatment (and IMO if you have

Assuming you meant IS_APPEND, I thought we only checked that at open
time, as part of requiring O_APPEND?

> O_APPEND on either file, you should get a failure as well).

generic_rw_checks (which is called by do_xchg_file_range) will send back
-EBADF if the file descriptors are O_APPEND.

--D



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux