linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.14/4.19/5.4/5.10/5.15 0/1] fs: reiserfs: remove useless new_opts in reiserfs_remount
@ 2023-01-26  8:58 Fedor Pchelkin
  2023-01-26  8:58 ` [PATCH 4.14/4.19/5.4/5.10/5.15 1/1] " Fedor Pchelkin
  0 siblings, 1 reply; 3+ messages in thread
From: Fedor Pchelkin @ 2023-01-26  8:58 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman
  Cc: Fedor Pchelkin, Jan Kara, Dongliang Mu, Al Viro, David Howells,
	reiserfs-devel, linux-kernel, Alexey Khoroshilov, lvc-project

As described in the following commit info, new_opts value is not used
anymore and is not cleaned on non-error paths -- it is a leak. The problem
has been fixed by the following patch which can be cleanly applied
to 4.14, 4.19, 5.4, 5.10, 5.15 branches.

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

* [PATCH 4.14/4.19/5.4/5.10/5.15 1/1] fs: reiserfs: remove useless new_opts in reiserfs_remount
  2023-01-26  8:58 [PATCH 4.14/4.19/5.4/5.10/5.15 0/1] fs: reiserfs: remove useless new_opts in reiserfs_remount Fedor Pchelkin
@ 2023-01-26  8:58 ` Fedor Pchelkin
  2023-01-26  9:13   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Fedor Pchelkin @ 2023-01-26  8:58 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman
  Cc: Fedor Pchelkin, Jan Kara, Dongliang Mu, Al Viro, David Howells,
	reiserfs-devel, linux-kernel, Alexey Khoroshilov, lvc-project

From: Dongliang Mu <mudongliangabcd@gmail.com>

commit 81dedaf10c20959bdf5624f9783f408df26ba7a4 upstream.

Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options
if not using generic_show_options") eliminates replace_mount_options
in reiserfs_remount, but does not handle the allocated new_opts,
it will cause memory leak in the reiserfs_remount.

Because new_opts is useless in reiserfs_mount, so we fix this bug by
removing the useless new_opts in reiserfs_remount.

Fixes: c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")
Link: https://lore.kernel.org/r/20211027143445.4156459-1-mudongliangabcd@gmail.com
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
 fs/reiserfs/super.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 58481f8d63d5..f7b05c6b3dcf 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -1437,7 +1437,6 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
 	unsigned long safe_mask = 0;
 	unsigned int commit_max_age = (unsigned int)-1;
 	struct reiserfs_journal *journal = SB_JOURNAL(s);
-	char *new_opts;
 	int err;
 	char *qf_names[REISERFS_MAXQUOTAS];
 	unsigned int qfmt = 0;
@@ -1445,10 +1444,6 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
 	int i;
 #endif
 
-	new_opts = kstrdup(arg, GFP_KERNEL);
-	if (arg && !new_opts)
-		return -ENOMEM;
-
 	sync_filesystem(s);
 	reiserfs_write_lock(s);
 
@@ -1599,7 +1594,6 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
 out_err_unlock:
 	reiserfs_write_unlock(s);
 out_err:
-	kfree(new_opts);
 	return err;
 }
 
-- 
2.34.1


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

* Re: [PATCH 4.14/4.19/5.4/5.10/5.15 1/1] fs: reiserfs: remove useless new_opts in reiserfs_remount
  2023-01-26  8:58 ` [PATCH 4.14/4.19/5.4/5.10/5.15 1/1] " Fedor Pchelkin
@ 2023-01-26  9:13   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-26  9:13 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: stable, Jan Kara, Dongliang Mu, Al Viro, David Howells,
	reiserfs-devel, linux-kernel, Alexey Khoroshilov, lvc-project

On Thu, Jan 26, 2023 at 11:58:46AM +0300, Fedor Pchelkin wrote:
> From: Dongliang Mu <mudongliangabcd@gmail.com>
> 
> commit 81dedaf10c20959bdf5624f9783f408df26ba7a4 upstream.
> 
> Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options
> if not using generic_show_options") eliminates replace_mount_options
> in reiserfs_remount, but does not handle the allocated new_opts,
> it will cause memory leak in the reiserfs_remount.
> 
> Because new_opts is useless in reiserfs_mount, so we fix this bug by
> removing the useless new_opts in reiserfs_remount.
> 
> Fixes: c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")
> Link: https://lore.kernel.org/r/20211027143445.4156459-1-mudongliangabcd@gmail.com
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> Signed-off-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
> ---
>  fs/reiserfs/super.c | 6 ------
>  1 file changed, 6 deletions(-)

Now queued up, thanks.

greg k-h

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

end of thread, other threads:[~2023-01-26  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26  8:58 [PATCH 4.14/4.19/5.4/5.10/5.15 0/1] fs: reiserfs: remove useless new_opts in reiserfs_remount Fedor Pchelkin
2023-01-26  8:58 ` [PATCH 4.14/4.19/5.4/5.10/5.15 1/1] " Fedor Pchelkin
2023-01-26  9:13   ` Greg Kroah-Hartman

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).