public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: check for negatives in xfs_exchange_range_checks()
@ 2024-05-04 11:27 Dan Carpenter
  2024-05-04 16:46 ` Markus Elfring
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Dan Carpenter @ 2024-05-04 11:27 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Chandan Babu R, linux-xfs, linux-kernel, kernel-janitors

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")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
From static analysis.  Untested.  Sorry!

 fs/xfs/xfs_exchrange.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/xfs/xfs_exchrange.c b/fs/xfs/xfs_exchrange.c
index c8a655c92c92..3465e152d928 100644
--- a/fs/xfs/xfs_exchrange.c
+++ b/fs/xfs/xfs_exchrange.c
@@ -337,6 +337,9 @@ xfs_exchange_range_checks(
 	if (IS_SWAPFILE(inode1) || IS_SWAPFILE(inode2))
 		return -ETXTBSY;
 
+	if (fxr->file1_offset < 0 || fxr->file2_offset < 0)
+		return -EINVAL;
+
 	size1 = i_size_read(inode1);
 	size2 = i_size_read(inode2);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-05-08  9:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-04 11:27 [PATCH] xfs: check for negatives in xfs_exchange_range_checks() Dan Carpenter
2024-05-04 16:46 ` Markus Elfring
2024-05-07  6:06 ` Christoph Hellwig
2024-05-07  6:33   ` Dan Carpenter
2024-05-07  6:40     ` Christoph Hellwig
2024-05-07 23:36       ` Darrick J. Wong
2024-05-07 23:33 ` Darrick J. Wong
2024-05-08  1:29 ` Dave Chinner
2024-05-08  2:26   ` Darrick J. Wong
2024-05-08  9:20   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox