lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 15 Aug 2022 08:59:11 +0800
From:   Dongliang Mu <mudongliangabcd@...il.com>
To:     Christian Brauner <brauner@...nel.org>
Cc:     Dongliang Mu <dzm91@...t.edu.cn>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Arve Hjønnevåg <arve@...roid.com>,
        Todd Kjos <tkjos@...roid.com>,
        Martijn Coenen <maco@...roid.com>,
        Joel Fernandes <joel@...lfernandes.org>,
        Carlos Llamas <cmllamas@...gle.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        Kees Cook <keescook@...omium.org>,
        syzkaller <syzkaller@...glegroups.com>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drivers: binderfs: fix memory leak in binderfs_fill_super

On Fri, Aug 12, 2022 at 10:18 PM Christian Brauner <brauner@...nel.org> wrote:
>
> On Fri, Aug 12, 2022 at 09:48:40PM +0800, Dongliang Mu wrote:
> > On Fri, Aug 12, 2022 at 9:41 PM Christian Brauner <brauner@...nel.org> wrote:
> > >
> > > On Fri, Aug 12, 2022 at 09:21:24PM +0800, Dongliang Mu wrote:
> > > > From: Dongliang Mu <mudongliangabcd@...il.com>
> > > >
> > > > In binderfs_fill_super, if s_root is not successfully initialized by
> > > > d_make_root, the previous allocated s_sb_info will not be freed since
> > > > generic_shutdown_super first checks if sb->s_root and then does
> > > > put_super operation. The put_super operation calls binderfs_put_super
> > > > to deallocate s_sb_info and put ipc_ns. This will lead to memory leak
> > > > in binderfs_fill_super.
> > > >
> > > > Fix this by invoking binderfs_put_super at error sites before s_root
> > > > is successfully initialized.
> > > >
> > > > Fixes: 095cf502b31e ("binderfs: port to new mount api")
> > > > Reported-by: syzkaller <syzkaller@...glegroups.com>
> > > > Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
> > > > ---
> > >
> > > Seems right but where's the full syzbot link to the issue?
> > > Also, wouldn't (untested) sm like the below be better?:
> >
> > I originally would like to change the order to object initialization,
> > but I am not sure if they can be exchanged since many *_fill_super are
> > ended with d_make_root.
> >
> > If you are sure about this exchange, I can resubmit a v2 patch.
>
> I think we should just always clean up the allocated memory in
> binderfs_fill_super() when d_make_root() fails and before via a goto
> block after the successful return. So we keep the cleanup in
> binderfs_fill_super() consistent and restricted to a single location.

Hi Christian,

So the final decision is to keep the cleanup or error handling code in
a single goto location at the end of binderfs_fill_super.

If I understand correctly, this change keeps the same semantic as mine
but is more elegant to maintain.

Powered by blists - more mailing lists