lkml.org 
[lkml]   [2009]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] cgroups: fix possible use after free
From
On Tue, Feb 10, 2009 at 1:31 AM, Li Zefan <lizf@cn.fujitsu.com> wrote:
> In cgroup_kill_sb(), root is freed before sb is detached from the list,
> so another sget() may find this sb and call cgroup_test_super(),
> which will access the root that has been freed.

I think that I'd assumed that by the time we get to cgroup_kill_sb()
there's no chance of the sb being resurrected by sget().

If anyone can call cgroup_test_super() on the sb that we're trying to
free, isn't that bad? Since even with this patch we free root just
after calling kill_litter_sb(), if anyone tries to reuse that super
block then they're toast.

Would it be better to set sb->s_fs_info to NULL, before calling
kill_litter_sb(), and have cgroup_test_super() just return 0 for any
sb with a NULL sb->s_fs_info.

Paul

>
> Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
> kernel/cgroup.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 5a54ff4..42fd3f2 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1122,8 +1122,8 @@ static void cgroup_kill_sb(struct super_block *sb) {
>
> mutex_unlock(&cgroup_mutex);
>
> - kfree(root);
> kill_litter_super(sb);
> + kfree(root);
> }
>
> static struct file_system_type cgroup_fs_type = {
> --
> 1.5.4.rc3
>


\
 
 \ /
  Last update: 2009-02-10 11:17    [W:0.067 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site