public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/9p: Fix invalid mount options/args
@ 2011-05-06 12:54 Prem Karat
  2011-05-08 17:51 ` [V9fs-developer] " Venkateswararao Jujjuri
  0 siblings, 1 reply; 3+ messages in thread
From: Prem Karat @ 2011-05-06 12:54 UTC (permalink / raw)
  To: v9fs-developer; +Cc: linux-fsdevel, linux-kernel


fs/9p: Fix invalid mount options/args

Without this fix, if any invalid mount options/args are passed while mouting the 9p fs,
no error (-EINVAL) is returned and default arg value is assigned.

This fix returns -EINVAL when an invalid arguement is found while parsing mount options.

Signed-off-by: Prem Karat <prem.karat@linux.vnet.ibm.com>
---
 fs/9p/v9fs.c |   43 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index c82b017..033c23e 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -78,6 +78,25 @@ static const match_table_t tokens = {
 	{Opt_err, NULL}
 };
 
+/* Interpret mount options for cache mode */
+static int get_cache_mode(char *s)
+{
+	int version = -EINVAL;
+
+	if (!strcmp(s, "loose")) {
+		version = CACHE_LOOSE;
+		P9_DPRINTK(P9_DEBUG_9P, "Cache mode: loose\n");
+	} else if (!strcmp(s, "fscache")) {
+		version = CACHE_FSCACHE;
+		P9_DPRINTK(P9_DEBUG_9P, "Cache mode: fscache\n");
+	} else if (!strcmp(s, "none")) {
+		version = CACHE_NONE;
+		P9_DPRINTK(P9_DEBUG_9P, "Cache mode: none\n");
+	} else
+		printk(KERN_INFO "9p: Unknown Cache mode %s.\n", s);
+	return version;
+}
+
 /**
  * v9fs_parse_options - parse mount options into session structure
  * @v9ses: existing v9fs session information
@@ -97,7 +116,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
 	/* setup defaults */
 	v9ses->afid = ~0;
 	v9ses->debug = 0;
-	v9ses->cache = 0;
+	v9ses->cache = CACHE_NONE;
 #ifdef CONFIG_9P_FSCACHE
 	v9ses->cachetag = NULL;
 #endif
@@ -171,13 +190,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
 				  "problem allocating copy of cache arg\n");
 				goto free_and_return;
 			}
+			ret = get_cache_mode(s);
+			if (ret == -EINVAL) {
+				kfree(s);
+				goto free_and_return;
+			}
 
-			if (strcmp(s, "loose") == 0)
-				v9ses->cache = CACHE_LOOSE;
-			else if (strcmp(s, "fscache") == 0)
-				v9ses->cache = CACHE_FSCACHE;
-			else
-				v9ses->cache = CACHE_NONE;
+			v9ses->cache = ret;
 			kfree(s);
 			break;
 
@@ -200,9 +219,15 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
 			} else {
 				v9ses->flags |= V9FS_ACCESS_SINGLE;
 				v9ses->uid = simple_strtoul(s, &e, 10);
-				if (*e != '\0')
-					v9ses->uid = ~0;
+				if (*e != '\0') {
+					ret = -EINVAL;
+					printk(KERN_INFO "9p: Unknown access "
+							"argument %s.\n", s);
+					kfree(s);
+					goto free_and_return;
+				}
 			}
+
 			kfree(s);
 			break;
 
-- 
1.7.4

-- 
Cheers,
Prem
Linux Technology Center,
IBM Systems & Technology Labs

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [V9fs-developer] [PATCH] fs/9p: Fix invalid mount options/args
  2011-05-06 12:54 [PATCH] fs/9p: Fix invalid mount options/args Prem Karat
@ 2011-05-08 17:51 ` Venkateswararao Jujjuri
  2011-05-11  4:44   ` Prem Karat
  0 siblings, 1 reply; 3+ messages in thread
From: Venkateswararao Jujjuri @ 2011-05-08 17:51 UTC (permalink / raw)
  To: Prem Karat; +Cc: v9fs-developer, linux-fsdevel, linux-kernel

On 05/06/2011 05:54 AM, Prem Karat wrote:
> fs/9p: Fix invalid mount options/args
>
> Without this fix, if any invalid mount options/args are passed while mouting the 9p fs,
> no error (-EINVAL) is returned and default arg value is assigned.
>
> This fix returns -EINVAL when an invalid arguement is found while parsing mount options.
Prem, Thanks for the patch.
Quick question..any reason why you have a new function for cache, and 
in-line here?

Thanks,
JV
> Signed-off-by: Prem Karat<prem.karat@linux.vnet.ibm.com>
> ---
>   fs/9p/v9fs.c |   43 ++++++++++++++++++++++++++++++++++---------
>   1 files changed, 34 insertions(+), 9 deletions(-)
>
> diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
> index c82b017..033c23e 100644
> --- a/fs/9p/v9fs.c
> +++ b/fs/9p/v9fs.c
> @@ -78,6 +78,25 @@ static const match_table_t tokens = {
>   	{Opt_err, NULL}
>   };
>
> +/* Interpret mount options for cache mode */
> +static int get_cache_mode(char *s)
> +{
> +	int version = -EINVAL;
> +
> +	if (!strcmp(s, "loose")) {
> +		version = CACHE_LOOSE;
> +		P9_DPRINTK(P9_DEBUG_9P, "Cache mode: loose\n");
> +	} else if (!strcmp(s, "fscache")) {
> +		version = CACHE_FSCACHE;
> +		P9_DPRINTK(P9_DEBUG_9P, "Cache mode: fscache\n");
> +	} else if (!strcmp(s, "none")) {
> +		version = CACHE_NONE;
> +		P9_DPRINTK(P9_DEBUG_9P, "Cache mode: none\n");
> +	} else
> +		printk(KERN_INFO "9p: Unknown Cache mode %s.\n", s);
> +	return version;
> +}
> +
>   /**
>    * v9fs_parse_options - parse mount options into session structure
>    * @v9ses: existing v9fs session information
> @@ -97,7 +116,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
>   	/* setup defaults */
>   	v9ses->afid = ~0;
>   	v9ses->debug = 0;
> -	v9ses->cache = 0;
> +	v9ses->cache = CACHE_NONE;
>   #ifdef CONFIG_9P_FSCACHE
>   	v9ses->cachetag = NULL;
>   #endif
> @@ -171,13 +190,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
>   				  "problem allocating copy of cache arg\n");
>   				goto free_and_return;
>   			}
> +			ret = get_cache_mode(s);
> +			if (ret == -EINVAL) {
> +				kfree(s);
> +				goto free_and_return;
> +			}
>
> -			if (strcmp(s, "loose") == 0)
> -				v9ses->cache = CACHE_LOOSE;
> -			else if (strcmp(s, "fscache") == 0)
> -				v9ses->cache = CACHE_FSCACHE;
> -			else
> -				v9ses->cache = CACHE_NONE;
> +			v9ses->cache = ret;
>   			kfree(s);
>   			break;
>
> @@ -200,9 +219,15 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
>   			} else {
>   				v9ses->flags |= V9FS_ACCESS_SINGLE;
>   				v9ses->uid = simple_strtoul(s,&e, 10);
> -				if (*e != '\0')
> -					v9ses->uid = ~0;
> +				if (*e != '\0') {
> +					ret = -EINVAL;
> +					printk(KERN_INFO "9p: Unknown access "
> +							"argument %s.\n", s);
> +					kfree(s);
> +					goto free_and_return;


> +				}
>   			}
> +
>   			kfree(s);
>   			break;
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [V9fs-developer] [PATCH] fs/9p: Fix invalid mount options/args
  2011-05-08 17:51 ` [V9fs-developer] " Venkateswararao Jujjuri
@ 2011-05-11  4:44   ` Prem Karat
  0 siblings, 0 replies; 3+ messages in thread
From: Prem Karat @ 2011-05-11  4:44 UTC (permalink / raw)
  To: Venkateswararao Jujjuri; +Cc: v9fs-developer, linux-fsdevel, linux-kernel

Hi JV,

Apologies for the delay in response & Thanks for reviewing it. 

On 05/08/11 10:51am, Venkateswararao Jujjuri wrote:
> On 05/06/2011 05:54 AM, Prem Karat wrote:
> >fs/9p: Fix invalid mount options/args
> >
> >Without this fix, if any invalid mount options/args are passed while mouting the 9p fs,
> >no error (-EINVAL) is returned and default arg value is assigned.
> >
> >This fix returns -EINVAL when an invalid arguement is found while parsing mount options.
> Prem, Thanks for the patch.
> Quick question..any reason why you have a new function for cache,
> and in-line here?
No specific reason. Just wanted the code to be in consistent with net/9p/client.c (get_protocol_version()).
> 
> Thanks,
> JV 
> >Signed-off-by: Prem Karat<prem.karat@linux.vnet.ibm.com>
> >---
> >  fs/9p/v9fs.c |   43 ++++++++++++++++++++++++++++++++++---------
> >  1 files changed, 34 insertions(+), 9 deletions(-)
> >
> >diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
> >index c82b017..033c23e 100644
> >--- a/fs/9p/v9fs.c
> >+++ b/fs/9p/v9fs.c
> >@@ -78,6 +78,25 @@ static const match_table_t tokens = {
> >  	{Opt_err, NULL}
> >  };
> >
> >+/* Interpret mount options for cache mode */
> >+static int get_cache_mode(char *s)
> >+{
> >+	int version = -EINVAL;
> >+
> >+	if (!strcmp(s, "loose")) {
> >+		version = CACHE_LOOSE;
> >+		P9_DPRINTK(P9_DEBUG_9P, "Cache mode: loose\n");
> >+	} else if (!strcmp(s, "fscache")) {
> >+		version = CACHE_FSCACHE;
> >+		P9_DPRINTK(P9_DEBUG_9P, "Cache mode: fscache\n");
> >+	} else if (!strcmp(s, "none")) {
> >+		version = CACHE_NONE;
> >+		P9_DPRINTK(P9_DEBUG_9P, "Cache mode: none\n");
> >+	} else
> >+		printk(KERN_INFO "9p: Unknown Cache mode %s.\n", s);
> >+	return version;
> >+}
> >+
> >  /**
> >   * v9fs_parse_options - parse mount options into session structure
> >   * @v9ses: existing v9fs session information
> >@@ -97,7 +116,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
> >  	/* setup defaults */
> >  	v9ses->afid = ~0;
> >  	v9ses->debug = 0;
> >-	v9ses->cache = 0;
> >+	v9ses->cache = CACHE_NONE;
> >  #ifdef CONFIG_9P_FSCACHE
> >  	v9ses->cachetag = NULL;
> >  #endif
> >@@ -171,13 +190,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
> >  				  "problem allocating copy of cache arg\n");
> >  				goto free_and_return;
> >  			}
> >+			ret = get_cache_mode(s);
> >+			if (ret == -EINVAL) {
> >+				kfree(s);
> >+				goto free_and_return;
> >+			}
> >
> >-			if (strcmp(s, "loose") == 0)
> >-				v9ses->cache = CACHE_LOOSE;
> >-			else if (strcmp(s, "fscache") == 0)
> >-				v9ses->cache = CACHE_FSCACHE;
> >-			else
> >-				v9ses->cache = CACHE_NONE;
> >+			v9ses->cache = ret;
> >  			kfree(s);
> >  			break;
> >
> >@@ -200,9 +219,15 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
> >  			} else {
> >  				v9ses->flags |= V9FS_ACCESS_SINGLE;
> >  				v9ses->uid = simple_strtoul(s,&e, 10);
> >-				if (*e != '\0')
> >-					v9ses->uid = ~0;
> >+				if (*e != '\0') {
> >+					ret = -EINVAL;
> >+					printk(KERN_INFO "9p: Unknown access "
> >+							"argument %s.\n", s);
> >+					kfree(s);
> >+					goto free_and_return;
> 
> 
> >+				}
> >  			}
> >+
> >  			kfree(s);
> >  			break;
> >
> 

-- 
Cheers,
Prem
Linux Technology Center,
IBM Systems & Technology Labs
DID: 41776362

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-11 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-06 12:54 [PATCH] fs/9p: Fix invalid mount options/args Prem Karat
2011-05-08 17:51 ` [V9fs-developer] " Venkateswararao Jujjuri
2011-05-11  4:44   ` Prem Karat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox