[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <51585a1-d236-5e26-a41-125ae4d0a0eb@linux.intel.com>
Date: Fri, 16 Sep 2022 17:05:56 +0300 (EEST)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Hyunwoo Kim <imv4bel@...il.com>
cc: arnd@...db.de, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] char: pcmcia: synclink_cs: Fix use-after-free in
mgslpc_ops
On Fri, 16 Sep 2022, Hyunwoo Kim wrote:
> On Fri, Sep 16, 2022 at 04:54:11PM +0300, Ilpo Järvinen wrote:
> > On Fri, 16 Sep 2022, Hyunwoo Kim wrote:
> >
> > > A race condition may occur if the user physically removes
> > > the pcmcia device while calling ioctl() for this tty device node.
> > >
> > > This is a race condition between the mgslpc_ioctl() function and
> > > the mgslpc_detach() function, which may eventually result in UAF.
> > >
> > > So, add a refcount check to mgslpc_detach() to free the structure
> > > after the tty device node is close()d.
> > >
> > > Signed-off-by: Hyunwoo Kim <imv4bel@...il.com>
> >
> > > @@ -2517,9 +2548,14 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
> > > if (debug_level >= DEBUG_LEVEL_INFO)
> > > printk("%s(%d):mgslpc_open(%s) success\n",
> > > __FILE__, __LINE__, info->device_name);
> > > +
> > > + kref_get(&info->refcnt);
> > > retval = 0;
> > > + mutex_unlock(&remove_mutex);
> > >
> > > + return retval;
> > > cleanup:
> > > + mutex_unlock(&remove_mutex);
> > > return retval;
> >
> > Just move the cleanup label instead.
>
> I'm sorry, but could you please explain a bit more?
The last two statements of the cleanup path and the path above it are
the same.
--
i.
Powered by blists - more mailing lists