* Use actual fd member shift in ext4_ioc_mfsync_info instead of
   hardcoded sizeof(__u32).
 * Add some spaces and new lines for readability.

https://virtuozzo.atlassian.net/browse/VSTOR-107255
Fixes: c266e3fb67ca ("ext4: add mfsync support")
Signed-off-by: Pavel Tikhomirov <ptikhomi...@virtuozzo.com>
---
 fs/ext4/ioctl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 66923dd1ddd4..738ed4d8cf5e 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1292,6 +1292,7 @@ static int ext4_mfsync(unsigned long arg)
 
        if (!ve_is_super(get_exec_env()))
                return -ENOTSUPP;
+
        if (copy_from_user(&mfsync, (struct ext4_ioc_mfsync_info *)arg,
                           sizeof(mfsync)))
                return -EFAULT;
@@ -1301,7 +1302,7 @@ static int ext4_mfsync(unsigned long arg)
        if (mfsync.size > NR_FILE)
                return -ENFILE;
 
-       usr_fd = (__u32 __user *) (arg + sizeof(__u32));
+       usr_fd = (__u32 __user *)&((struct ext4_ioc_mfsync_info *)arg)->fd[0];
 
        filpp = kzalloc(mfsync.size * sizeof(*filpp), GFP_KERNEL);
        if (!filpp)
@@ -1311,6 +1312,7 @@ static int ext4_mfsync(unsigned long arg)
                kfree(filpp);
                return -ENOMEM;
        }
+
        for (i = 0; i < mfsync.size; i++) {
                int fd;
                int ret;
@@ -1321,8 +1323,8 @@ static int ext4_mfsync(unsigned long arg)
                        goto mfsync_fput;
 
                /* negative fd means fdata_sync */
-               flags[i] = (fd & (1<< 31)) != 0;
-               fd &= ~(1<< 31);
+               flags[i] = (fd & (1 << 31)) != 0;
+               fd &= ~(1 << 31);
 
                err = -EBADF;
                filpp[i] = fget(fd);
-- 
2.50.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to