diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-05-02 11:31:12 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-05-02 11:31:12 -0700 |
commit | f66ed1ebbfde37631fba289f7c399eaa70632abf (patch) | |
tree | 26d2658584a7ec456a55fdc3f63bcc5089220ba6 | |
parent | 29a47f456d6213a3173722a098a3a18865ea4db3 (diff) | |
parent | b75dfde1212991b24b220c3995101c60a7b8ae74 (diff) | |
download | linux-stable-f66ed1ebbfde37631fba289f7c399eaa70632abf.tar.gz linux-stable-f66ed1ebbfde37631fba289f7c399eaa70632abf.tar.bz2 linux-stable-f66ed1ebbfde37631fba289f7c399eaa70632abf.zip |
Merge tag 'iomap-5.7-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull iomap fix from Darrick Wong:
"Hoist the check for an unrepresentable FIBMAP return value into
ioctl_fibmap.
The internal kernel function can handle 64-bit values (and is needed
to fix a regression on ext4 + jbd2). It is only the userspace ioctl
that is so old that it cannot deal"
* tag 'iomap-5.7-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
fibmap: Warn and return an error in case of block > INT_MAX
-rw-r--r-- | fs/ioctl.c | 8 | ||||
-rw-r--r-- | fs/iomap/fiemap.c | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/fs/ioctl.c b/fs/ioctl.c index 282d45be6f45..5e80b40bc1b5 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -55,6 +55,7 @@ EXPORT_SYMBOL(vfs_ioctl); static int ioctl_fibmap(struct file *filp, int __user *p) { struct inode *inode = file_inode(filp); + struct super_block *sb = inode->i_sb; int error, ur_block; sector_t block; @@ -71,6 +72,13 @@ static int ioctl_fibmap(struct file *filp, int __user *p) block = ur_block; error = bmap(inode, &block); + if (block > INT_MAX) { + error = -ERANGE; + pr_warn_ratelimited("[%s/%d] FS: %s File: %pD4 would truncate fibmap result\n", + current->comm, task_pid_nr(current), + sb->s_id, filp); + } + if (error) ur_block = 0; else diff --git a/fs/iomap/fiemap.c b/fs/iomap/fiemap.c index bccf305ea9ce..d55e8f491a5e 100644 --- a/fs/iomap/fiemap.c +++ b/fs/iomap/fiemap.c @@ -117,10 +117,7 @@ iomap_bmap_actor(struct inode *inode, loff_t pos, loff_t length, if (iomap->type == IOMAP_MAPPED) { addr = (pos - iomap->offset + iomap->addr) >> inode->i_blkbits; - if (addr > INT_MAX) - WARN(1, "would truncate bmap result\n"); - else - *bno = addr; + *bno = addr; } return 0; } |