aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJann Horn <jann@thejh.net>2016-07-19 20:30:30 -0400
committerDave Chinner <david@fromorbit.com>2016-07-19 20:30:30 -0400
commit7f1b62457b58f9bb586a1b2ff7fe271b56196bd2 (patch)
treed3a6277509f53a981b42cffbbe379807d029a3fe
parent1a695a905c18548062509178b98bc91e67510864 (diff)
xfs: fix type confusion in xfs_ioc_swapext
When calling fdget() in xfs_ioc_swapext(), we need to verify that the file descriptors passed into the ioctl point to XFS inodes before we start operations on them. If we don't do this, we could be referencing arbitrary kernel memory as an XFS inode. THis could lead to memory corruption and/or performing locking operations on attacker-chosen structures in kernel memory. [dchinner: rewrite commit message ] [dchinner: add comment explaining new check ] Signed-off-by: Jann Horn <jann@thejh.net> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_ioctl.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index dbca7375deef..408f3ad348ab 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1575,6 +1575,17 @@ xfs_ioc_swapext(
1575 goto out_put_tmp_file; 1575 goto out_put_tmp_file;
1576 } 1576 }
1577 1577
1578 /*
1579 * We need to ensure that the fds passed in point to XFS inodes
1580 * before we cast and access them as XFS structures as we have no
1581 * control over what the user passes us here.
1582 */
1583 if (f.file->f_op != &xfs_file_operations ||
1584 tmp.file->f_op != &xfs_file_operations) {
1585 error = -EINVAL;
1586 goto out_put_tmp_file;
1587 }
1588
1578 ip = XFS_I(file_inode(f.file)); 1589 ip = XFS_I(file_inode(f.file));
1579 tip = XFS_I(file_inode(tmp.file)); 1590 tip = XFS_I(file_inode(tmp.file));
1580 1591