2022-09-19 09:55:44

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v4] char: pcmcia: scr24x_cs: Fix use-after-free in scr24x_fops

On Mon, Sep 19, 2022 at 02:38:01AM -0700, Hyunwoo Kim wrote:
> A race condition may occur if the user physically removes the
> pcmcia device while calling open() for this char device node.
>
> This is a race condition between the scr24x_open() function and
> the scr24x_remove() function, which may eventually result in UAF.
>
> So, add a mutex to the scr24x_open() and scr24x_remove() functions
> to avoid race contidion of krefs.
>
> Signed-off-by: Hyunwoo Kim <[email protected]>
> Reported-by: kernel test robot <[email protected]>

The robot did not report this original problem :(

> ---
> drivers/char/pcmcia/scr24x_cs.c | 73 +++++++++++++++++++++++----------
> 1 file changed, 52 insertions(+), 21 deletions(-)

You failed to put below the --- line what changed from previous versions
as the documentation asks for.

thanks,

greg k-h


2022-09-19 11:11:43

by Hyunwoo Kim

[permalink] [raw]
Subject: Re: [PATCH v4] char: pcmcia: scr24x_cs: Fix use-after-free in scr24x_fops

On Mon, Sep 19, 2022 at 11:45:27AM +0200, Greg KH wrote:
> On Mon, Sep 19, 2022 at 02:38:01AM -0700, Hyunwoo Kim wrote:
> > A race condition may occur if the user physically removes the
> > pcmcia device while calling open() for this char device node.
> >
> > This is a race condition between the scr24x_open() function and
> > the scr24x_remove() function, which may eventually result in UAF.
> >
> > So, add a mutex to the scr24x_open() and scr24x_remove() functions
> > to avoid race contidion of krefs.
> >
> > Signed-off-by: Hyunwoo Kim <[email protected]>
> > Reported-by: kernel test robot <[email protected]>
>
> The robot did not report this original problem :(
>
> > ---
> > drivers/char/pcmcia/scr24x_cs.c | 73 +++++++++++++++++++++++----------
> > 1 file changed, 52 insertions(+), 21 deletions(-)
>
> You failed to put below the --- line what changed from previous versions
> as the documentation asks for.

thank you for telling me.

I submitted a fixed v5 patch.


Regards,
Hyunwoo Kim.