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

From: Hyunwoo Kim
Date: Mon Sep 19 2022 - 06:42:26 EST


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 <imv4bel@xxxxxxxxx>
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> 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.