Skip to content

Commit 8f97d1e

Browse files
amir73ilMiklos Szeredi
authored andcommitted
vfs: fix FIGETBSZ ioctl on an overlayfs file
Some anon_bdev filesystems (e.g. overlayfs, ceph) don't have s_blocksize set. Returning zero from FIGETBSZ ioctl results in a Floating point exception from the e2fsprogs utility filefrag, which divides the size of the file with the value returned by FIGETBSZ. Fix the interface by returning -EINVAL for these filesystems. Fixes: d1d04ef ("ovl: stack file ops") Cc: <stable@vger.kernel.org> # v4.19 Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 1f244dc commit 8f97d1e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/ioctl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,9 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
669669
return ioctl_fiemap(filp, arg);
670670

671671
case FIGETBSZ:
672+
/* anon_bdev filesystems may not have a block size */
673+
if (!inode->i_sb->s_blocksize)
674+
return -EINVAL;
672675
return put_user(inode->i_sb->s_blocksize, argp);
673676

674677
case FICLONE:

0 commit comments

Comments
 (0)