xfs: prevent swapext from operating on write-only files
commitc7e97b0249f59d7e32b19ef71899cc083cab1b9b
authorDan Rosenberg <dan.j.rosenberg@gmail.com>
Thu, 24 Jun 2010 02:07:47 +0000 (24 12:07 +1000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 2 Aug 2010 17:30:17 +0000 (2 10:30 -0700)
treed115bfb58bbd49c054bcc555ae5cd65d405f56d1
parent8bffdea32019685abb0ad2035ab5870eecb887d4
xfs: prevent swapext from operating on write-only files

commit 1817176a86352f65210139d4c794ad2d19fc6b63 upstream.

This patch prevents user "foo" from using the SWAPEXT ioctl to swap
a write-only file owned by user "bar" into a file owned by "foo" and
subsequently reading it.  It does so by checking that the file
descriptors passed to the ioctl are also opened for reading.

Signed-off-by: Dan Rosenberg <dan.j.rosenberg@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/xfs/xfs_dfrag.c