The commit is pushed to "branch-rh8-4.18.0-305.3.1.vz8.7.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-305.3.1.vz8.7.2
------>
commit 4c17c3856a6c4ad270604679aad8afdd3c7205c9
Author: Kirill Tkhai <[email protected]>
Date:   Thu Aug 5 19:09:11 2021 +0300

    fuse: Fix fuse_parse_param() kio_name handling #PSBM-131962
    
    https://jira.sw.ru/browse/PSBM-131962
    Fixes: 462dea7b00b1 ("fuse: add kdirect io engine v0.1")
    
    Signed-off-by: Kirill Tkhai <[email protected]>
---
 fs/fuse/fuse_i.h | 2 +-
 fs/fuse/inode.c  | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 57c673386ff9..014c44ec9e26 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -586,7 +586,7 @@ struct fuse_fs_context {
        unsigned int max_read;
        unsigned int blksize;
        const char *subtype;
-       char kio_name[FUSE_KIO_NAME];
+       char kio_name[FUSE_KIO_NAME + 1];
 
        /* DAX device, may be NULL */
        struct dax_device *dax_dev;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 81308d08a8ad..ca6363720daf 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -779,11 +779,11 @@ static int fuse_parse_param(struct fs_context *fc, struct 
fs_parameter *param)
        case OPT_KIO_NAME: {
                if (!ve_is_super(get_exec_env()))
                        return -EPERM;
+               if (param->size > FUSE_KIO_NAME)
+                       return -EINVAL;
 
-               /* FIXME: if len(param->string) > FUSE_KIO_NAME,
-                * there will be no string termination
-                */
-               strncpy(ctx->kio_name, param->string, FUSE_KIO_NAME);
+               strncpy(ctx->kio_name, param->string, param->size);
+               ctx->kio_name[FUSE_KIO_NAME] = '\0';
                ctx->kdirect_io = 1;
 
                kfree(param->string);
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to