Message ID | 39b4bf94f6723831a9798237bb1b4ae14da04d98.1587555962.git.riteshh@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | ext4/overlayfs: fiemap related fixes | expand |
On Thu 23-04-20 16:17:56, Ritesh Harjani wrote: > Underlying fs may not be able to handle the length in fiemap > beyond sb->s_maxbytes. So similar to how VFS ioctl does it, > add fiemap_check_ranges() check in ovl_fiemap() as well > before calling underlying fs i_op->fiemap() call. > > Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com> > --- > fs/overlayfs/inode.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) Yeah, makes sense. You can add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > > diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c > index 79e8994e3bc1..9bcd2e96faad 100644 > --- a/fs/overlayfs/inode.c > +++ b/fs/overlayfs/inode.c > @@ -455,16 +455,21 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > int err; > struct inode *realinode = ovl_inode_real(inode); > const struct cred *old_cred; > + u64 length; > > if (!realinode->i_op->fiemap) > return -EOPNOTSUPP; > > + err = fiemap_check_ranges(realinode->i_sb, start, len, &length); > + if (err) > + return err; > + > old_cred = ovl_override_creds(inode->i_sb); > > if (fieinfo->fi_flags & FIEMAP_FLAG_SYNC) > filemap_write_and_wait(realinode->i_mapping); > > - err = realinode->i_op->fiemap(realinode, fieinfo, start, len); > + err = realinode->i_op->fiemap(realinode, fieinfo, start, length); > revert_creds(old_cred); > > return err; > -- > 2.21.0 >
On Thu, Apr 23, 2020 at 1:48 PM Ritesh Harjani <riteshh@linux.ibm.com> wrote: > > Underlying fs may not be able to handle the length in fiemap > beyond sb->s_maxbytes. So similar to how VFS ioctl does it, > add fiemap_check_ranges() check in ovl_fiemap() as well > before calling underlying fs i_op->fiemap() call. > > Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com> > --- > fs/overlayfs/inode.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c > index 79e8994e3bc1..9bcd2e96faad 100644 > --- a/fs/overlayfs/inode.c > +++ b/fs/overlayfs/inode.c > @@ -455,16 +455,21 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > int err; > struct inode *realinode = ovl_inode_real(inode); > const struct cred *old_cred; > + u64 length; To be more clear, I would call that reallen, but apart from that, you may add: Reviewed-by: Amir Goldstein <amir73il@gmail.com> Thanks, Amir.
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 79e8994e3bc1..9bcd2e96faad 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -455,16 +455,21 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, int err; struct inode *realinode = ovl_inode_real(inode); const struct cred *old_cred; + u64 length; if (!realinode->i_op->fiemap) return -EOPNOTSUPP; + err = fiemap_check_ranges(realinode->i_sb, start, len, &length); + if (err) + return err; + old_cred = ovl_override_creds(inode->i_sb); if (fieinfo->fi_flags & FIEMAP_FLAG_SYNC) filemap_write_and_wait(realinode->i_mapping); - err = realinode->i_op->fiemap(realinode, fieinfo, start, len); + err = realinode->i_op->fiemap(realinode, fieinfo, start, length); revert_creds(old_cred); return err;
Underlying fs may not be able to handle the length in fiemap beyond sb->s_maxbytes. So similar to how VFS ioctl does it, add fiemap_check_ranges() check in ovl_fiemap() as well before calling underlying fs i_op->fiemap() call. Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com> --- fs/overlayfs/inode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)