[1/3] fuse: Fix parse_fuse_opt() return values wrong interpretation

Submitted by Kirill Tkhai on Oct. 30, 2018, 8:55 a.m.

Details

Message ID 154088967102.13528.14025873745406142343.stgit@localhost.localdomain
State New
Series "Series without cover letter"
Headers show

Commit Message

Kirill Tkhai Oct. 30, 2018, 8:55 a.m.
This function returns not 0 in case of success, and 0 in case
of failure. So, error values like -EPERM are interpreted as
success, which is wrong. Fix that.
Note, that fuse has generic EINVAL return value for all types
of unacceptable parameters.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/inode.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index ca9a146d39fa..0695b79c4c50 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -688,19 +688,19 @@  static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
 
 		case OPT_WBCACHE:
 			if (!ve_is_super(get_exec_env()) && !fuse_ve_odirect)
-				return -EPERM;
+				return 0;
 			d->writeback_cache = 1;
 			break;
 
 		case OPT_ODIRECT:
 			if (!ve_is_super(get_exec_env()) && !fuse_ve_odirect)
-				return -EPERM;
+				return 0;
 			d->flags |= FUSE_ODIRECT;
 			break;
 
 		case OPT_UMOUNT_WAIT:
 			if (!ve_is_super(get_exec_env()) && !fuse_ve_odirect)
-				return -EPERM;
+				return 0;
 			d->flags |= FUSE_UMOUNT_WAIT;
 			break;
 
@@ -711,7 +711,7 @@  static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
 			char *name;
 			name = match_strdup(&args[0]);
 			if (!name)
-				return 1;
+				return 0;
 
 			strncpy(d->kio_name, name, FUSE_KIO_NAME);
 			d->flags |= FUSE_KDIRECT_IO;

Comments

Pavel Butsykin Oct. 30, 2018, 12:26 p.m.
On 30.10.2018 11:55, Kirill Tkhai wrote:
> This function returns not 0 in case of success, and 0 in case
> of failure. So, error values like -EPERM are interpreted as
> success, which is wrong. Fix that.
> Note, that fuse has generic EINVAL return value for all types
> of unacceptable parameters.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Reviewed-by: Pavel Butsykin <pbutsykin@virtuozzo.com>

> ---
>   fs/fuse/inode.c |    8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
> index ca9a146d39fa..0695b79c4c50 100644
> --- a/fs/fuse/inode.c
> +++ b/fs/fuse/inode.c
> @@ -688,19 +688,19 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
>   
>   		case OPT_WBCACHE:
>   			if (!ve_is_super(get_exec_env()) && !fuse_ve_odirect)
> -				return -EPERM;
> +				return 0;
>   			d->writeback_cache = 1;
>   			break;
>   
>   		case OPT_ODIRECT:
>   			if (!ve_is_super(get_exec_env()) && !fuse_ve_odirect)
> -				return -EPERM;
> +				return 0;
>   			d->flags |= FUSE_ODIRECT;
>   			break;
>   
>   		case OPT_UMOUNT_WAIT:
>   			if (!ve_is_super(get_exec_env()) && !fuse_ve_odirect)
> -				return -EPERM;
> +				return 0;
>   			d->flags |= FUSE_UMOUNT_WAIT;
>   			break;
>   
> @@ -711,7 +711,7 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
>   			char *name;
>   			name = match_strdup(&args[0]);
>   			if (!name)
> -				return 1;
> +				return 0;
>   
>   			strncpy(d->kio_name, name, FUSE_KIO_NAME);
>   			d->flags |= FUSE_KDIRECT_IO;
>