[Devel] [PATCH RH8] fuse: #PSBM-131962

Kirill Tkhai ktkhai at virtuozzo.com
Thu Jul 22 15:05:49 MSK 2021


Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 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);




More information about the Devel mailing list