diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-02-09 00:44:41 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-02-09 00:44:41 +0300 |
commit | b85080c106b1290eaebf100ee97babef833047d8 (patch) | |
tree | 1895b63d83fd7858314009602ce40fb44b4fee1d /fs/ioctl.c | |
parent | c9d35ee049b40f1d73e890bf88dd55f83b1e9be8 (diff) | |
parent | 0a061743af93f472687b8c69b0d539d1f12f3fd2 (diff) | |
download | linux-b85080c106b1290eaebf100ee97babef833047d8.tar.xz |
Merge tag 'compat-ioctl-fix' of git://git.kernel.org:/pub/scm/linux/kernel/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
Diffstat (limited to 'fs/ioctl.c')
-rw-r--r-- | fs/ioctl.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/ioctl.c b/fs/ioctl.c index 72d6848fb6ad..282d45be6f45 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -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); @@ -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); |