Skip to content

Commit b85080c

Browse files
committed
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
2 parents c9d35ee + 0a06174 commit b85080c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/ioctl.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,9 @@ static int compat_ioctl_preallocate(struct file *file, int mode,
536536

537537
static int file_ioctl(struct file *filp, unsigned int cmd, int __user *p)
538538
{
539-
struct inode *inode = file_inode(filp);
540-
541539
switch (cmd) {
542540
case FIBMAP:
543541
return ioctl_fibmap(filp, p);
544-
case FIONREAD:
545-
return put_user(i_size_read(inode) - filp->f_pos, p);
546542
case FS_IOC_RESVSP:
547543
case FS_IOC_RESVSP64:
548544
return ioctl_preallocate(filp, 0, p);
@@ -734,6 +730,13 @@ static int do_vfs_ioctl(struct file *filp, unsigned int fd,
734730
case FIDEDUPERANGE:
735731
return ioctl_file_dedupe_range(filp, argp);
736732

733+
case FIONREAD:
734+
if (!S_ISREG(inode->i_mode))
735+
return vfs_ioctl(filp, cmd, arg);
736+
737+
return put_user(i_size_read(inode) - filp->f_pos,
738+
(int __user *)argp);
739+
737740
default:
738741
if (S_ISREG(inode->i_mode))
739742
return file_ioctl(filp, cmd, argp);

0 commit comments

Comments
 (0)