Skip to content

Commit

Permalink
xfs: fix type confusion in xfs_ioc_swapext
Browse files Browse the repository at this point in the history
Without this check, the following XFS_I invocations would return bad
pointers when used on non-XFS inodes (perhaps pointers into preceding
allocator chunks).

This could be used by an attacker to trick xfs_swap_extents into
performing locking operations on attacker-chosen structures in kernel
memory, potentially leading to code execution in the kernel.  (I have
not investigated how likely this is to be usable for an attack in
practice.)

Signed-off-by: Jann Horn <jann@thejh.net>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jann Horn authored and Linus Torvalds committed Jul 15, 2016
1 parent aa93d1f commit 3e0a396
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/xfs/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,12 @@ xfs_ioc_swapext(
goto out_put_tmp_file;
}

if (f.file->f_op != &xfs_file_operations ||
tmp.file->f_op != &xfs_file_operations) {
error = -EINVAL;
goto out_put_tmp_file;
}

ip = XFS_I(file_inode(f.file));
tip = XFS_I(file_inode(tmp.file));

Expand Down

0 comments on commit 3e0a396

Please sign in to comment.