[Devel,RH7] ioctl: use sb from file inode when make FIGETBSZ check

Submitted by Pavel Tikhomirov on Feb. 9, 2017, 4:11 p.m.

Details

Message ID 20170209161119.10447-1-ptikhomirov@virtuozzo.com
State New
Series "ioctl: use sb from file inode when make FIGETBSZ check"
Headers show

Commit Message

Pavel Tikhomirov Feb. 9, 2017, 4:11 p.m.
On overlayfs blocksize on super_block is not set, and FIGETBSZ
returns blocksize of an underlying fs, so we also need to do our
check for underlying sb.

Rebase commit a3ee37c28983 ("rh7: import RHEL7 kernel-3.10.0-514.el7")
brought ms commit 4bacc9c9234c ("overlayfs: Make f_path always point
to the overlay and f_inode to the underlay"), so now super block
filp->f_path.dentry->d_inode->i_sb is of overlayfs, not of the
underlying fs as was before.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 fs/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/ioctl.c b/fs/ioctl.c
index f0d0cf9..ae33299 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -590,7 +590,7 @@  int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
 
 	case FIGETBSZ:
 	{
-		struct super_block *sb = filp->f_path.dentry->d_inode->i_sb;
+		struct super_block *sb = inode->i_sb;
 		if (sb->s_blocksize == 1ul << sb->s_blocksize_bits)
 			return put_user(inode->i_sb->s_blocksize, argp);
 		/* fail through */

Comments

Pavel Tikhomirov Feb. 9, 2017, 4:13 p.m.
On 02/09/2017 07:11 PM, Pavel Tikhomirov wrote:
> On overlayfs blocksize on super_block is not set, and FIGETBSZ
> returns blocksize of an underlying fs, so we also need to do our
> check for underlying sb.
>
> Rebase commit a3ee37c28983 ("rh7: import RHEL7 kernel-3.10.0-514.el7")
> brought ms commit 4bacc9c9234c ("overlayfs: Make f_path always point
> to the overlay and f_inode to the underlay"), so now super block
> filp->f_path.dentry->d_inode->i_sb is of overlayfs, not of the
> underlying fs as was before.

https://jira.sw.ru/browse/PSBM-58480

>
> Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
> ---
>  fs/ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index f0d0cf9..ae33299 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -590,7 +590,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
>
>  	case FIGETBSZ:
>  	{
> -		struct super_block *sb = filp->f_path.dentry->d_inode->i_sb;
> +		struct super_block *sb = inode->i_sb;
>  		if (sb->s_blocksize == 1ul << sb->s_blocksize_bits)
>  			return put_user(inode->i_sb->s_blocksize, argp);
>  		/* fail through */
>
Kirill Tkhai Feb. 13, 2017, 12:56 p.m.
On 09.02.2017 19:11, Pavel Tikhomirov wrote:
> On overlayfs blocksize on super_block is not set, and FIGETBSZ
> returns blocksize of an underlying fs, so we also need to do our
> check for underlying sb.
> 
> Rebase commit a3ee37c28983 ("rh7: import RHEL7 kernel-3.10.0-514.el7")
> brought ms commit 4bacc9c9234c ("overlayfs: Make f_path always point
> to the overlay and f_inode to the underlay"), so now super block
> filp->f_path.dentry->d_inode->i_sb is of overlayfs, not of the
> underlying fs as was before.
> 
> Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
> ---
>  fs/ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index f0d0cf9..ae33299 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -590,7 +590,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
>  
>  	case FIGETBSZ:
>  	{
> -		struct super_block *sb = filp->f_path.dentry->d_inode->i_sb;
> +		struct super_block *sb = inode->i_sb;
>  		if (sb->s_blocksize == 1ul << sb->s_blocksize_bits)
>  			return put_user(inode->i_sb->s_blocksize, argp);

I think, we do not need this check at all. See [PATCH] fs: Revert "ms: FIGETBSZ ioctl safety checks", I've sent.

>  		/* fail through */
>