public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: richard@nod.at, yi.zhang@huawei.com,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] ubifs: Don't parse authentication mount options in remount process
Date: Wed, 30 Sep 2020 08:58:13 +0200	[thread overview]
Message-ID: <20200930065813.GC11648@pengutronix.de> (raw)
In-Reply-To: <20200929124531.941873-2-chengzhihao1@huawei.com>

On Tue, Sep 29, 2020 at 08:45:30PM +0800, Zhihao Cheng wrote:
> There is no need to dump authentication options while remounting,
> because authentication initialization can only be doing once in
> the first mount process. Dumping authentication mount options in
> remount process may cause memory leak if UBIFS has already been
> mounted with old authentication mount options.
> 
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> Cc: <stable@vger.kernel.org>  # 4.20+
> Fixes: d8a22773a12c6d7 ("ubifs: Enable authentication support")

Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>

Sascha

> ---
>  fs/ubifs/super.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 6f85cd618766..9796f5df2f7f 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -1110,14 +1110,20 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
>  			break;
>  		}
>  		case Opt_auth_key:
> -			c->auth_key_name = kstrdup(args[0].from, GFP_KERNEL);
> -			if (!c->auth_key_name)
> -				return -ENOMEM;
> +			if (!is_remount) {
> +				c->auth_key_name = kstrdup(args[0].from,
> +								GFP_KERNEL);
> +				if (!c->auth_key_name)
> +					return -ENOMEM;
> +			}
>  			break;
>  		case Opt_auth_hash_name:
> -			c->auth_hash_name = kstrdup(args[0].from, GFP_KERNEL);
> -			if (!c->auth_hash_name)
> -				return -ENOMEM;
> +			if (!is_remount) {
> +				c->auth_hash_name = kstrdup(args[0].from,
> +								GFP_KERNEL);
> +				if (!c->auth_hash_name)
> +					return -ENOMEM;
> +			}
>  			break;
>  		case Opt_ignore:
>  			break;
> -- 
> 2.25.4
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2020-09-30  6:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 12:45 [PATCH 1/3] ubifs: Fix a memleak after dumping authentication mount options Zhihao Cheng
2020-09-29 12:45 ` [PATCH 2/3] ubifs: Don't parse authentication mount options in remount process Zhihao Cheng
2020-09-30  6:58   ` Sascha Hauer [this message]
2020-09-29 12:45 ` [PATCH 3/3] ubifs: mount_ubifs: Release authentication resource in error handling path Zhihao Cheng
2020-09-30  6:44   ` Sascha Hauer
2020-09-30  7:09 ` [PATCH 1/3] ubifs: Fix a memleak after dumping authentication mount options Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200930065813.GC11648@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=chengzhihao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox