提交 1817176a 编写于 作者: D Dan Rosenberg 提交者: Dave Chinner

xfs: prevent swapext from operating on write-only files

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: NDan Rosenberg <dan.j.rosenberg@gmail.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
上级 7e27d6e7
...@@ -69,7 +69,9 @@ xfs_swapext( ...@@ -69,7 +69,9 @@ xfs_swapext(
goto out; goto out;
} }
if (!(file->f_mode & FMODE_WRITE) || (file->f_flags & O_APPEND)) { if (!(file->f_mode & FMODE_WRITE) ||
!(file->f_mode & FMODE_READ) ||
(file->f_flags & O_APPEND)) {
error = XFS_ERROR(EBADF); error = XFS_ERROR(EBADF);
goto out_put_file; goto out_put_file;
} }
...@@ -81,6 +83,7 @@ xfs_swapext( ...@@ -81,6 +83,7 @@ xfs_swapext(
} }
if (!(tmp_file->f_mode & FMODE_WRITE) || if (!(tmp_file->f_mode & FMODE_WRITE) ||
!(tmp_file->f_mode & FMODE_READ) ||
(tmp_file->f_flags & O_APPEND)) { (tmp_file->f_flags & O_APPEND)) {
error = XFS_ERROR(EBADF); error = XFS_ERROR(EBADF);
goto out_put_tmp_file; goto out_put_tmp_file;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册