Messages in this thread | | | Date | Fri, 12 Aug 2022 16:18:49 +0200 | From | Christian Brauner <> | Subject | Re: [PATCH] drivers: binderfs: fix memory leak in binderfs_fill_super |
| |
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@kernel.org> wrote: > > > > On Fri, Aug 12, 2022 at 09:21:24PM +0800, Dongliang Mu wrote: > > > From: Dongliang Mu <mudongliangabcd@gmail.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@googlegroups.com> > > > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.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.
| |