From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Hyunwoo Kim <imv4bel@gmail.com>
Cc: arnd@arndb.de, Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] char: pcmcia: synclink_cs: Fix use-after-free in mgslpc_ops
Date: Fri, 16 Sep 2022 17:05:56 +0300 (EEST) [thread overview]
Message-ID: <51585a1-d236-5e26-a41-125ae4d0a0eb@linux.intel.com> (raw)
In-Reply-To: <20220916140353.GA235538@ubuntu>
[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]
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@gmail.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.
prev parent reply other threads:[~2022-09-16 14:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 13:47 [PATCH v3] char: pcmcia: synclink_cs: Fix use-after-free in mgslpc_ops Hyunwoo Kim
2022-09-16 13:54 ` Ilpo Järvinen
2022-09-16 14:03 ` Hyunwoo Kim
2022-09-16 14:05 ` Ilpo Järvinen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51585a1-d236-5e26-a41-125ae4d0a0eb@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=imv4bel@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.