Re: [PATCH 01/14] misc: fastrpc: Fix use-after-free and race in fastrpc_map_find

From: Abel Vesa
Date: Fri Sep 02 2022 - 10:59:15 EST


On 22-09-02 15:25:10, Greg Kroah-Hartman wrote:
> On Fri, Sep 02, 2022 at 04:13:31PM +0300, Abel Vesa wrote:
> > Currently, there is a race window between the point when the mutex is
> > unlocked in fastrpc_map_lookup and the reference count increasing
> > (fastrpc_map_get) in fastrpc_map_find, which can also lead to
> > use-after-free.
> >
> > So lets merge fastrpc_map_find into fastrpc_map_lookup which allows us
> > to both protect the maps list by also taking the &fl->lock spinlock and
> > the reference count, since the spinlock will be released only after.
> > Add take_ref argument to make this suitable for all callers.
> >
> > Co-developed-by: Ola Jeppsson <ola@xxxxxxxx>
> > Signed-off-by: Ola Jeppsson <ola@xxxxxxxx>
> > Signed-off-by: Abel Vesa <abel.vesa@xxxxxxxxxx>
> > ---
> > drivers/misc/fastrpc.c | 41 +++++++++++++++++++++--------------------
> > 1 file changed, 21 insertions(+), 20 deletions(-)
>
> What commit does this fix? Should it go to stable trees?

Will specify in the next version.

>
> Try splitting this series up into 2, one for 6.0-final with bugfixes to
> resolve issues found, and the next one on top of that for new features.

Fair point. Will do in the next version.

>
> thanks,
>
> greg k-h