linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] hfs: fix potential refcnt problem of nls module
@ 2018-04-17  7:05 Chengguang Xu
  2018-04-17  7:05 ` [PATCH 2/2] hfsplus: " Chengguang Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chengguang Xu @ 2018-04-17  7:05 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: dhowells, kstewart, gregkh, tglx, pombredanne, linux-kernel,
	Chengguang Xu

When specifying iocharset/codepage multiple times in a mount,
current option parsing will cause inaccurate refcount of nls
module. Hence, call unload_nls for previous one in this case.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/hfs/super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 1738767..6a5f6fd 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -329,8 +329,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
 				return 0;
 			}
 			p = match_strdup(&args[0]);
-			if (p)
+			if (p) {
+				unload_nls(hsb->nls_disk);
 				hsb->nls_disk = load_nls(p);
+			}
 			if (!hsb->nls_disk) {
 				pr_err("unable to load codepage \"%s\"\n", p);
 				kfree(p);
@@ -344,8 +346,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
 				return 0;
 			}
 			p = match_strdup(&args[0]);
-			if (p)
+			if (p) {
+				unload_nls(hsb->nls_io);
 				hsb->nls_io = load_nls(p);
+			}
 			if (!hsb->nls_io) {
 				pr_err("unable to load iocharset \"%s\"\n", p);
 				kfree(p);
-- 
1.8.3.1

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

* [PATCH 2/2] hfsplus: fix potential refcnt problem of nls module
  2018-04-17  7:05 [PATCH 1/2] hfs: fix potential refcnt problem of nls module Chengguang Xu
@ 2018-04-17  7:05 ` Chengguang Xu
  2018-04-18 17:11   ` Viacheslav Dubeyko
  2018-04-18 19:43   ` Andrew Morton
  2018-04-18 17:10 ` [PATCH 1/2] hfs: " Viacheslav Dubeyko
  2018-04-18 19:42 ` Andrew Morton
  2 siblings, 2 replies; 7+ messages in thread
From: Chengguang Xu @ 2018-04-17  7:05 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: dhowells, kstewart, gregkh, tglx, pombredanne, linux-kernel,
	Chengguang Xu

When specifying nls option multiple times in a mount,
current option parsing will cause inaccurate refcount of nls
module. Hence, call unload_nls for previous one in this case.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/hfsplus/options.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
index 047e05c..068d4e2 100644
--- a/fs/hfsplus/options.c
+++ b/fs/hfsplus/options.c
@@ -171,8 +171,10 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
 				return 0;
 			}
 			p = match_strdup(&args[0]);
-			if (p)
+			if (p) {
+				unload_nls(sbi->nls);
 				sbi->nls = load_nls(p);
+			}
 			if (!sbi->nls) {
 				pr_err("unable to load nls mapping \"%s\"\n",
 				       p);
-- 
1.8.3.1

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

* Re: [PATCH 1/2] hfs: fix potential refcnt problem of nls module
  2018-04-17  7:05 [PATCH 1/2] hfs: fix potential refcnt problem of nls module Chengguang Xu
  2018-04-17  7:05 ` [PATCH 2/2] hfsplus: " Chengguang Xu
@ 2018-04-18 17:10 ` Viacheslav Dubeyko
  2018-04-18 19:42 ` Andrew Morton
  2 siblings, 0 replies; 7+ messages in thread
From: Viacheslav Dubeyko @ 2018-04-18 17:10 UTC (permalink / raw)
  To: Chengguang Xu, linux-fsdevel
  Cc: dhowells, kstewart, gregkh, tglx, pombredanne, linux-kernel,
	Andrew Morton

On Tue, 2018-04-17 at 15:05 +0800, Chengguang Xu wrote:
> When specifying iocharset/codepage multiple times in a mount,
> current option parsing will cause inaccurate refcount of nls
> module. Hence, call unload_nls for previous one in this case.
> 
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>


Looks good.

Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>

Thanks,
Vyacheslav Dubeyko.


> ---
>  fs/hfs/super.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/hfs/super.c b/fs/hfs/super.c
> index 1738767..6a5f6fd 100644
> --- a/fs/hfs/super.c
> +++ b/fs/hfs/super.c
> @@ -329,8 +329,10 @@ static int parse_options(char *options, struct
> hfs_sb_info *hsb)
>  				return 0;
>  			}
>  			p = match_strdup(&args[0]);
> -			if (p)
> +			if (p) {
> +				unload_nls(hsb->nls_disk);
>  				hsb->nls_disk = load_nls(p);
> +			}
>  			if (!hsb->nls_disk) {
>  				pr_err("unable to load codepage
> \"%s\"\n", p);
>  				kfree(p);
> @@ -344,8 +346,10 @@ static int parse_options(char *options, struct
> hfs_sb_info *hsb)
>  				return 0;
>  			}
>  			p = match_strdup(&args[0]);
> -			if (p)
> +			if (p) {
> +				unload_nls(hsb->nls_io);
>  				hsb->nls_io = load_nls(p);
> +			}
>  			if (!hsb->nls_io) {
>  				pr_err("unable to load iocharset
> \"%s\"\n", p);
>  				kfree(p);

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

* Re: [PATCH 2/2] hfsplus: fix potential refcnt problem of nls module
  2018-04-17  7:05 ` [PATCH 2/2] hfsplus: " Chengguang Xu
@ 2018-04-18 17:11   ` Viacheslav Dubeyko
  2018-04-18 19:43   ` Andrew Morton
  1 sibling, 0 replies; 7+ messages in thread
From: Viacheslav Dubeyko @ 2018-04-18 17:11 UTC (permalink / raw)
  To: Chengguang Xu, linux-fsdevel
  Cc: dhowells, kstewart, gregkh, tglx, pombredanne, linux-kernel,
	Andrew Morton

On Tue, 2018-04-17 at 15:05 +0800, Chengguang Xu wrote:
> When specifying nls option multiple times in a mount,
> current option parsing will cause inaccurate refcount of nls
> module. Hence, call unload_nls for previous one in this case.
> 
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>


Looks good.

Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>

Thanks,
Vyacheslav Dubeyko.


> ---
>  fs/hfsplus/options.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
> index 047e05c..068d4e2 100644
> --- a/fs/hfsplus/options.c
> +++ b/fs/hfsplus/options.c
> @@ -171,8 +171,10 @@ int hfsplus_parse_options(char *input, struct
> hfsplus_sb_info *sbi)
>  				return 0;
>  			}
>  			p = match_strdup(&args[0]);
> -			if (p)
> +			if (p) {
> +				unload_nls(sbi->nls);
>  				sbi->nls = load_nls(p);
> +			}
>  			if (!sbi->nls) {
>  				pr_err("unable to load nls mapping
> \"%s\"\n",
>  				       p);

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

* Re: [PATCH 1/2] hfs: fix potential refcnt problem of nls module
  2018-04-17  7:05 [PATCH 1/2] hfs: fix potential refcnt problem of nls module Chengguang Xu
  2018-04-17  7:05 ` [PATCH 2/2] hfsplus: " Chengguang Xu
  2018-04-18 17:10 ` [PATCH 1/2] hfs: " Viacheslav Dubeyko
@ 2018-04-18 19:42 ` Andrew Morton
  2018-04-19  1:18   ` cgxu519
  2 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2018-04-18 19:42 UTC (permalink / raw)
  To: Chengguang Xu
  Cc: linux-fsdevel, dhowells, kstewart, gregkh, tglx, pombredanne,
	linux-kernel

On Tue, 17 Apr 2018 15:05:32 +0800 Chengguang Xu <cgxu519@gmx.com> wrote:

> When specifying iocharset/codepage multiple times in a mount,
> current option parsing will cause inaccurate refcount of nls
> module. Hence, call unload_nls for previous one in this case.
> 
> ...
>
> --- a/fs/hfs/super.c
> +++ b/fs/hfs/super.c
> @@ -329,8 +329,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
>  				return 0;
>  			}
>  			p = match_strdup(&args[0]);
> -			if (p)
> +			if (p) {
> +				unload_nls(hsb->nls_disk);
>  				hsb->nls_disk = load_nls(p);
> +			}
>  			if (!hsb->nls_disk) {
>  				pr_err("unable to load codepage \"%s\"\n", p);
>  				kfree(p);
> @@ -344,8 +346,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
>  				return 0;
>  			}
>  			p = match_strdup(&args[0]);
> -			if (p)
> +			if (p) {
> +				unload_nls(hsb->nls_io);
>  				hsb->nls_io = load_nls(p);
> +			}
>  			if (!hsb->nls_io) {
>  				pr_err("unable to load iocharset \"%s\"\n", p);
>  				kfree(p);

Confused.

			break;
: 		case opt_codepage:
: 			if (hsb->nls_disk) {
: 				pr_err("unable to change codepage\n");
: 				return 0;
: 			}

Here, hsb->nls_disk is known to be zero.

: 			p = match_strdup(&args[0]);
: 			if (p) {
: 				unload_nls(hsb->nls_disk);

So this will always do unload_nls(0).

: 				hsb->nls_disk = load_nls(p);
: 			}

And the same applies to your opt_iocharset change.

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

* Re: [PATCH 2/2] hfsplus: fix potential refcnt problem of nls module
  2018-04-17  7:05 ` [PATCH 2/2] hfsplus: " Chengguang Xu
  2018-04-18 17:11   ` Viacheslav Dubeyko
@ 2018-04-18 19:43   ` Andrew Morton
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2018-04-18 19:43 UTC (permalink / raw)
  To: Chengguang Xu
  Cc: linux-fsdevel, dhowells, kstewart, gregkh, tglx, pombredanne,
	linux-kernel

On Tue, 17 Apr 2018 15:05:33 +0800 Chengguang Xu <cgxu519@gmx.com> wrote:

> When specifying nls option multiple times in a mount,
> current option parsing will cause inaccurate refcount of nls
> module. Hence, call unload_nls for previous one in this case.
> 
> --- a/fs/hfsplus/options.c
> +++ b/fs/hfsplus/options.c
> @@ -171,8 +171,10 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
>  				return 0;
>  			}
>  			p = match_strdup(&args[0]);
> -			if (p)
> +			if (p) {
> +				unload_nls(sbi->nls);
>  				sbi->nls = load_nls(p);
> +			}
>  			if (!sbi->nls) {
>  				pr_err("unable to load nls mapping \"%s\"\n",
>  				       p);

Same problem as in [patch 1/2]

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

* Re: [PATCH 1/2] hfs: fix potential refcnt problem of nls module
  2018-04-18 19:42 ` Andrew Morton
@ 2018-04-19  1:18   ` cgxu519
  0 siblings, 0 replies; 7+ messages in thread
From: cgxu519 @ 2018-04-19  1:18 UTC (permalink / raw)
  To: Andrew Morton
  Cc: cgxu519, linux-fsdevel, dhowells, kstewart, gregkh, tglx,
	pombredanne, linux-kernel

锟斤拷 2018锟斤拷4锟斤拷19锟秸o拷锟斤拷锟斤拷3:42锟斤拷Andrew Morton <akpm@linux-foundation.org> 写锟斤拷锟斤拷
> 
> On Tue, 17 Apr 2018 15:05:32 +0800 Chengguang Xu <cgxu519@gmx.com> wrote:
> 
>> When specifying iocharset/codepage multiple times in a mount,
>> current option parsing will cause inaccurate refcount of nls
>> module. Hence, call unload_nls for previous one in this case.
>> 
>> ...
>> 
>> --- a/fs/hfs/super.c
>> +++ b/fs/hfs/super.c
>> @@ -329,8 +329,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
>> 				return 0;
>> 			}
>> 			p = match_strdup(&args[0]);
>> -			if (p)
>> +			if (p) {
>> +				unload_nls(hsb->nls_disk);
>> 				hsb->nls_disk = load_nls(p);
>> +			}
>> 			if (!hsb->nls_disk) {
>> 				pr_err("unable to load codepage \"%s\"\n", p);
>> 				kfree(p);
>> @@ -344,8 +346,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
>> 				return 0;
>> 			}
>> 			p = match_strdup(&args[0]);
>> -			if (p)
>> +			if (p) {
>> +				unload_nls(hsb->nls_io);
>> 				hsb->nls_io = load_nls(p);
>> +			}
>> 			if (!hsb->nls_io) {
>> 				pr_err("unable to load iocharset \"%s\"\n", p);
>> 				kfree(p);
> 
> Confused.
> 
> 			break;
> : 		case opt_codepage:
> : 			if (hsb->nls_disk) {
> : 				pr_err("unable to change codepage\n");
> : 				return 0;
> : 			}
> 
> Here, hsb->nls_disk is known to be zero.
> 
> : 			p = match_strdup(&args[0]);
> : 			if (p) {
> : 				unload_nls(hsb->nls_disk);
> 
> So this will always do unload_nls(0).
> 
> : 				hsb->nls_disk = load_nls(p);
> : 			}
> 
> And the same applies to your opt_iocharset change.

You are right. Sorry I just misread this part, please just drop the patch.

Thanks.

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

end of thread, other threads:[~2018-04-19  1:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-17  7:05 [PATCH 1/2] hfs: fix potential refcnt problem of nls module Chengguang Xu
2018-04-17  7:05 ` [PATCH 2/2] hfsplus: " Chengguang Xu
2018-04-18 17:11   ` Viacheslav Dubeyko
2018-04-18 19:43   ` Andrew Morton
2018-04-18 17:10 ` [PATCH 1/2] hfs: " Viacheslav Dubeyko
2018-04-18 19:42 ` Andrew Morton
2018-04-19  1:18   ` cgxu519

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).