On Mon, May 06, 2024 at 11:06:17PM -0700, Christoph Hellwig wrote: > On Sat, May 04, 2024 at 02:27:36PM +0300, Dan Carpenter wrote: > > The fxr->file1_offset and fxr->file2_offset variables come from the user > > in xfs_ioc_exchange_range(). They are size loff_t which is an s64. > > Check the they aren't negative. > > > > Fixes: 9a64d9b3109d ("xfs: introduce new file range exchange ioctl") > > In this commit file1_offset and file2_offset are u64. They used to > be u64 in the initial submission, but we changed that as part of the > review process. I've just checked again, and I think it was loff_t in that commit. There are two related structs, the one that's userspace API and the one that's internal. The userspace API is u64 but internally it's loff_t. fs/xfs/libxfs/xfs_fs.h 818 struct xfs_exchange_range { 819 __s32 file1_fd; 820 __u32 pad; /* must be zeroes */ 821 __u64 file1_offset; /* file1 offset, bytes */ 822 __u64 file2_offset; /* file2 offset, bytes */ 823 __u64 length; /* bytes to exchange */ 824 825 __u64 flags; /* see XFS_EXCHANGE_RANGE_* below */ 826 }; fs/xfs/xfs_exchrange.h 16 struct xfs_exchrange { 17 struct file *file1; 18 struct file *file2; 19 20 loff_t file1_offset; 21 loff_t file2_offset; 22 u64 length; 23 24 u64 flags; /* XFS_EXCHANGE_RANGE flags */ 25 }; regards, dan carpenter