All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/9p: fix potential refcnt problem of trans module
@ 2018-03-27 12:49 Chengguang Xu
  2018-03-28  2:10 ` [V9fs-developer] " jiangyiwen
  0 siblings, 1 reply; 4+ messages in thread
From: Chengguang Xu @ 2018-03-27 12:49 UTC (permalink / raw)
  To: ericvh, rminnich, lucho, davem; +Cc: v9fs-developer, netdev, Chengguang Xu

When specifying trans_mod multiple times in a mount,
it may cause inaccurate refcount of trans module. Also,
in the error case of option parsing, we should put the
trans module if we have already got.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 net/9p/client.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/9p/client.c b/net/9p/client.c
index b433aff..7ccfb4b 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -190,7 +190,9 @@ static int parse_opts(char *opts, struct p9_client *clnt)
 				p9_debug(P9_DEBUG_ERROR,
 					 "problem allocating copy of trans arg\n");
 				goto free_and_return;
-			 }
+			}
+
+			v9fs_put_trans(clnt->trans_mod);
 			clnt->trans_mod = v9fs_get_trans_by_name(s);
 			if (clnt->trans_mod == NULL) {
 				pr_info("Could not find request transport: %s\n",
@@ -226,6 +228,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
 	}
 
 free_and_return:
+	v9fs_put_trans(clnt->trans_mod);
 	kfree(tmp_options);
 	return ret;
 }
-- 
1.8.3.1

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

* Re: [V9fs-developer] [PATCH] net/9p: fix potential refcnt problem of trans module
  2018-03-27 12:49 [PATCH] net/9p: fix potential refcnt problem of trans module Chengguang Xu
@ 2018-03-28  2:10 ` jiangyiwen
  2018-03-28  2:52   ` cgxu519
  0 siblings, 1 reply; 4+ messages in thread
From: jiangyiwen @ 2018-03-28  2:10 UTC (permalink / raw)
  To: Chengguang Xu, ericvh, rminnich, lucho, davem; +Cc: v9fs-developer, netdev

On 2018/3/27 20:49, Chengguang Xu wrote:
> When specifying trans_mod multiple times in a mount,
> it may cause inaccurate refcount of trans module. Also,
> in the error case of option parsing, we should put the
> trans module if we have already got.
> 
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
>  net/9p/client.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/9p/client.c b/net/9p/client.c
> index b433aff..7ccfb4b 100644
> --- a/net/9p/client.c
> +++ b/net/9p/client.c
> @@ -190,7 +190,9 @@ static int parse_opts(char *opts, struct p9_client *clnt)
>  				p9_debug(P9_DEBUG_ERROR,
>  					 "problem allocating copy of trans arg\n");
>  				goto free_and_return;
> -			 }
> +			}
> +
> +			v9fs_put_trans(clnt->trans_mod);

I think this should return error if using multiple times
in a mount.

>  			clnt->trans_mod = v9fs_get_trans_by_name(s);
>  			if (clnt->trans_mod == NULL) {
>  				pr_info("Could not find request transport: %s\n",
> @@ -226,6 +228,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
>  	}
>  
>  free_and_return:
> +	v9fs_put_trans(clnt->trans_mod);

This looks good.

>  	kfree(tmp_options);
>  	return ret;
>  }
> 

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

* Re: [V9fs-developer] [PATCH] net/9p: fix potential refcnt problem of trans module
  2018-03-28  2:10 ` [V9fs-developer] " jiangyiwen
@ 2018-03-28  2:52   ` cgxu519
  2018-03-28  3:38     ` jiangyiwen
  0 siblings, 1 reply; 4+ messages in thread
From: cgxu519 @ 2018-03-28  2:52 UTC (permalink / raw)
  To: jiangyiwen
  Cc: cgxu519, ericvh, rminnich, lucho, davem, v9fs-developer, netdev

在 2018年3月28日,上午10:10,jiangyiwen <jiangyiwen@huawei.com> 写道:
> 
> On 2018/3/27 20:49, Chengguang Xu wrote:
>> When specifying trans_mod multiple times in a mount,
>> it may cause inaccurate refcount of trans module. Also,
>> in the error case of option parsing, we should put the
>> trans module if we have already got.
>> 
>> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
>> ---
>> net/9p/client.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/net/9p/client.c b/net/9p/client.c
>> index b433aff..7ccfb4b 100644
>> --- a/net/9p/client.c
>> +++ b/net/9p/client.c
>> @@ -190,7 +190,9 @@ static int parse_opts(char *opts, struct p9_client *clnt)
>> 				p9_debug(P9_DEBUG_ERROR,
>> 					 "problem allocating copy of trans arg\n");
>> 				goto free_and_return;
>> -			 }
>> +			}
>> +
>> +			v9fs_put_trans(clnt->trans_mod);
> 
> I think this should return error if using multiple times
> in a mount.

Fail or retake are just different policies how to deal with this kind of situation,
most filesystems in kernel choose retaking new value, so we’d better keep consistence
with others unless there is a necessary reason.

Thanks,
Chengguang.


> 
>> 			clnt->trans_mod = v9fs_get_trans_by_name(s);
>> 			if (clnt->trans_mod == NULL) {
>> 				pr_info("Could not find request transport: %s\n",
>> @@ -226,6 +228,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
>> 	}
>> 
>> free_and_return:
>> +	v9fs_put_trans(clnt->trans_mod);
> 
> This looks good.
> 
>> 	kfree(tmp_options);
>> 	return ret;
>> }
>> 
> 
> 

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

* Re: [V9fs-developer] [PATCH] net/9p: fix potential refcnt problem of trans module
  2018-03-28  2:52   ` cgxu519
@ 2018-03-28  3:38     ` jiangyiwen
  0 siblings, 0 replies; 4+ messages in thread
From: jiangyiwen @ 2018-03-28  3:38 UTC (permalink / raw)
  To: cgxu519; +Cc: ericvh, rminnich, lucho, davem, v9fs-developer, netdev

On 2018/3/28 10:52, cgxu519@gmx.com wrote:
> 在 2018年3月28日,上午10:10,jiangyiwen <jiangyiwen@huawei.com> 写道:
>>
>> On 2018/3/27 20:49, Chengguang Xu wrote:
>>> When specifying trans_mod multiple times in a mount,
>>> it may cause inaccurate refcount of trans module. Also,
>>> in the error case of option parsing, we should put the
>>> trans module if we have already got.
>>>
>>> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
>>> ---
>>> net/9p/client.c | 5 ++++-
>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/net/9p/client.c b/net/9p/client.c
>>> index b433aff..7ccfb4b 100644
>>> --- a/net/9p/client.c
>>> +++ b/net/9p/client.c
>>> @@ -190,7 +190,9 @@ static int parse_opts(char *opts, struct p9_client *clnt)
>>> 				p9_debug(P9_DEBUG_ERROR,
>>> 					 "problem allocating copy of trans arg\n");
>>> 				goto free_and_return;
>>> -			 }
>>> +			}
>>> +
>>> +			v9fs_put_trans(clnt->trans_mod);
>>
>> I think this should return error if using multiple times
>> in a mount.
> 
> Fail or retake are just different policies how to deal with this kind of situation,
> most filesystems in kernel choose retaking new value, so we’d better keep consistence
> with others unless there is a necessary reason.
> 
> Thanks,
> Chengguang.
> 

Yes, you're right, most filesystems retake indeed the new value.

Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>

> 
>>
>>> 			clnt->trans_mod = v9fs_get_trans_by_name(s);
>>> 			if (clnt->trans_mod == NULL) {
>>> 				pr_info("Could not find request transport: %s\n",
>>> @@ -226,6 +228,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
>>> 	}
>>>
>>> free_and_return:
>>> +	v9fs_put_trans(clnt->trans_mod);
>>
>> This looks good.
>>
>>> 	kfree(tmp_options);
>>> 	return ret;
>>> }
>>>
>>
>>
> 
> 
> .
> 

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

end of thread, other threads:[~2018-03-28  3:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 12:49 [PATCH] net/9p: fix potential refcnt problem of trans module Chengguang Xu
2018-03-28  2:10 ` [V9fs-developer] " jiangyiwen
2018-03-28  2:52   ` cgxu519
2018-03-28  3:38     ` jiangyiwen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.