* [PATCH] fs: reiserfs: free new_opts in reiserfs_remount
@ 2021-10-27 3:39 Dongliang Mu
2021-10-27 9:46 ` Jan Kara
0 siblings, 1 reply; 5+ messages in thread
From: Dongliang Mu @ 2021-10-27 3:39 UTC (permalink / raw)
To: Yu Kuai, Dongliang Mu, Jan Kara, Miklos Szeredi, Al Viro,
David Howells
Cc: reiserfs-devel, linux-kernel
Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options
if not using generic_show_options") eliminates replace_mount_options
in reiserfs, but did not handle the allocated new_opts,
it will cause memory leak in the reiserfs_remount.
Fix this by freeing new_opts in the reiserfs_remount temporarily.
Fixes: c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
fs/reiserfs/super.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 58481f8d63d5..b36865c8b66a 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -1594,6 +1594,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
}
out_ok_unlocked:
+ kfree(new_opts);
return 0;
out_err_unlock:
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] fs: reiserfs: free new_opts in reiserfs_remount
2021-10-27 3:39 [PATCH] fs: reiserfs: free new_opts in reiserfs_remount Dongliang Mu
@ 2021-10-27 9:46 ` Jan Kara
2021-10-27 10:19 ` Dongliang Mu
0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2021-10-27 9:46 UTC (permalink / raw)
To: Dongliang Mu
Cc: Yu Kuai, Jan Kara, Miklos Szeredi, Al Viro, David Howells,
reiserfs-devel, linux-kernel
On Wed 27-10-21 11:39:25, Dongliang Mu wrote:
> Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options
> if not using generic_show_options") eliminates replace_mount_options
> in reiserfs, but did not handle the allocated new_opts,
> it will cause memory leak in the reiserfs_remount.
>
> Fix this by freeing new_opts in the reiserfs_remount temporarily.
>
> Fixes: c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Thanks for the patch but I can see that new_opts is not actually used at
all in reiserfs_remount() so we should perhaps just remove them (including
kstrdup() et al).
Honza
> ---
> fs/reiserfs/super.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
> index 58481f8d63d5..b36865c8b66a 100644
> --- a/fs/reiserfs/super.c
> +++ b/fs/reiserfs/super.c
> @@ -1594,6 +1594,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
> }
>
> out_ok_unlocked:
> + kfree(new_opts);
> return 0;
>
> out_err_unlock:
> --
> 2.25.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] fs: reiserfs: free new_opts in reiserfs_remount
2021-10-27 9:46 ` Jan Kara
@ 2021-10-27 10:19 ` Dongliang Mu
2021-10-27 11:15 ` Jan Kara
0 siblings, 1 reply; 5+ messages in thread
From: Dongliang Mu @ 2021-10-27 10:19 UTC (permalink / raw)
To: Jan Kara
Cc: Yu Kuai, Miklos Szeredi, Al Viro, David Howells, reiserfs-devel,
linux-kernel
On Wed, Oct 27, 2021 at 5:46 PM Jan Kara <jack@suse.cz> wrote:
>
> On Wed 27-10-21 11:39:25, Dongliang Mu wrote:
> > Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options
> > if not using generic_show_options") eliminates replace_mount_options
> > in reiserfs, but did not handle the allocated new_opts,
> > it will cause memory leak in the reiserfs_remount.
> >
> > Fix this by freeing new_opts in the reiserfs_remount temporarily.
> >
> > Fixes: c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")
> > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
>
> Thanks for the patch but I can see that new_opts is not actually used at
> all in reiserfs_remount() so we should perhaps just remove them (including
> kstrdup() et al).
That's also a plan. Since I am not sure if maintainers will use
new_opts anymore, So I propose a temporary patch to fix this memory
leak.
If you think new_opts is not used anymore, let's remove all the code
related to new_opts.
>
> Honza
>
> > ---
> > fs/reiserfs/super.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
> > index 58481f8d63d5..b36865c8b66a 100644
> > --- a/fs/reiserfs/super.c
> > +++ b/fs/reiserfs/super.c
> > @@ -1594,6 +1594,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
> > }
> >
> > out_ok_unlocked:
> > + kfree(new_opts);
> > return 0;
> >
> > out_err_unlock:
> > --
> > 2.25.1
> >
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] fs: reiserfs: free new_opts in reiserfs_remount
2021-10-27 10:19 ` Dongliang Mu
@ 2021-10-27 11:15 ` Jan Kara
2021-10-27 12:29 ` Dongliang Mu
0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2021-10-27 11:15 UTC (permalink / raw)
To: Dongliang Mu
Cc: Jan Kara, Yu Kuai, Miklos Szeredi, Al Viro, David Howells,
reiserfs-devel, linux-kernel
On Wed 27-10-21 18:19:00, Dongliang Mu wrote:
> On Wed, Oct 27, 2021 at 5:46 PM Jan Kara <jack@suse.cz> wrote:
> >
> > On Wed 27-10-21 11:39:25, Dongliang Mu wrote:
> > > Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options
> > > if not using generic_show_options") eliminates replace_mount_options
> > > in reiserfs, but did not handle the allocated new_opts,
> > > it will cause memory leak in the reiserfs_remount.
> > >
> > > Fix this by freeing new_opts in the reiserfs_remount temporarily.
> > >
> > > Fixes: c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")
> > > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> >
> > Thanks for the patch but I can see that new_opts is not actually used at
> > all in reiserfs_remount() so we should perhaps just remove them (including
> > kstrdup() et al).
>
> That's also a plan. Since I am not sure if maintainers will use
> new_opts anymore, So I propose a temporary patch to fix this memory
> leak.
>
> If you think new_opts is not used anymore, let's remove all the code
> related to new_opts.
If it is ever needed again, we can always add it. Please just remove it.
Thanks!
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] fs: reiserfs: free new_opts in reiserfs_remount
2021-10-27 11:15 ` Jan Kara
@ 2021-10-27 12:29 ` Dongliang Mu
0 siblings, 0 replies; 5+ messages in thread
From: Dongliang Mu @ 2021-10-27 12:29 UTC (permalink / raw)
To: Jan Kara
Cc: Yu Kuai, Miklos Szeredi, Al Viro, David Howells, reiserfs-devel,
linux-kernel
On Wed, Oct 27, 2021 at 7:15 PM Jan Kara <jack@suse.cz> wrote:
>
> On Wed 27-10-21 18:19:00, Dongliang Mu wrote:
> > On Wed, Oct 27, 2021 at 5:46 PM Jan Kara <jack@suse.cz> wrote:
> > >
> > > On Wed 27-10-21 11:39:25, Dongliang Mu wrote:
> > > > Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options
> > > > if not using generic_show_options") eliminates replace_mount_options
> > > > in reiserfs, but did not handle the allocated new_opts,
> > > > it will cause memory leak in the reiserfs_remount.
> > > >
> > > > Fix this by freeing new_opts in the reiserfs_remount temporarily.
> > > >
> > > > Fixes: c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")
> > > > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> > >
> > > Thanks for the patch but I can see that new_opts is not actually used at
> > > all in reiserfs_remount() so we should perhaps just remove them (including
> > > kstrdup() et al).
> >
> > That's also a plan. Since I am not sure if maintainers will use
> > new_opts anymore, So I propose a temporary patch to fix this memory
> > leak.
> >
> > If you think new_opts is not used anymore, let's remove all the code
> > related to new_opts.
>
> If it is ever needed again, we can always add it. Please just remove it.
Sure. I will send a patch v2.
> Thanks!
>
> Honza
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-27 12:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-27 3:39 [PATCH] fs: reiserfs: free new_opts in reiserfs_remount Dongliang Mu
2021-10-27 9:46 ` Jan Kara
2021-10-27 10:19 ` Dongliang Mu
2021-10-27 11:15 ` Jan Kara
2021-10-27 12:29 ` Dongliang Mu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox