xfs: prevent swapext from operating on write-only files
authorDan Rosenberg <dan.j.rosenberg@gmail.com>
Thu, 24 Jun 2010 02:07:47 +0000 (12:07 +1000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 10 Aug 2010 17:20:44 +0000 (10:20 -0700)
commit7a4c13ac72f77cbbaa780c7a53e6bb8d586ff2d9
treecf874996be1cb3224c5b35fe83b15d9790098c79
parent001632030b5d98ac56c65416a884a90a33a40097
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