From: Amir Goldstein Date: Thu, 11 Oct 2018 14:38:14 +0000 (+0300) Subject: vfs: fix FIGETBSZ ioctl on an overlayfs file X-Git-Tag: rel_imx_4.19.35_1.1.0~8648 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=cbd6cfd2ee3621fd607169a130933820548851a0;p=linux.git vfs: fix FIGETBSZ ioctl on an overlayfs file commit 8f97d1e99149a7f1aa19e47a51b09764382a482e upstream. 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: d1d04ef8572b ("ovl: stack file ops") Cc: # v4.19 Signed-off-by: Amir Goldstein Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ioctl.c b/fs/ioctl.c index 2005529af560..0400297c8d72 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -669,6 +669,9 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, return ioctl_fiemap(filp, arg); case FIGETBSZ: + /* anon_bdev filesystems may not have a block size */ + if (!inode->i_sb->s_blocksize) + return -EINVAL; return put_user(inode->i_sb->s_blocksize, argp); case FICLONE: