Skip to content

Commit

Permalink
Merge tag 'compat-ioctl-fix' of git://git.kernel.org:/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/arnd/playground

Pull compat-ioctl fix from Arnd Bergmann:
 "One patch in the compat-ioctl series broke 32-bit rootfs for multiple
  people testing on 64-bit kernels. Let's fix it in -rc1 before others
  run into the same issue"

* tag 'compat-ioctl-fix' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground:
  compat_ioctl: fix FIONREAD on devices
  • Loading branch information
torvalds committed Feb 8, 2020
2 parents c9d35ee + 0a06174 commit b85080c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,9 @@ static int compat_ioctl_preallocate(struct file *file, int mode,

static int file_ioctl(struct file *filp, unsigned int cmd, int __user *p)
{
struct inode *inode = file_inode(filp);

switch (cmd) {
case FIBMAP:
return ioctl_fibmap(filp, p);
case FIONREAD:
return put_user(i_size_read(inode) - filp->f_pos, p);
case FS_IOC_RESVSP:
case FS_IOC_RESVSP64:
return ioctl_preallocate(filp, 0, p);
Expand Down Expand Up @@ -734,6 +730,13 @@ static int do_vfs_ioctl(struct file *filp, unsigned int fd,
case FIDEDUPERANGE:
return ioctl_file_dedupe_range(filp, argp);

case FIONREAD:
if (!S_ISREG(inode->i_mode))
return vfs_ioctl(filp, cmd, arg);

return put_user(i_size_read(inode) - filp->f_pos,
(int __user *)argp);

default:
if (S_ISREG(inode->i_mode))
return file_ioctl(filp, cmd, argp);
Expand Down

0 comments on commit b85080c

Please sign in to comment.