All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hyunwoo Kim <imv4bel@gmail.com>
To: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	laforge@gnumonks.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	linux-kernel@vger.kernel.org,
	"Paul Fulghum" <paulkf@microgate.com>,
	akpm@osdl.org, "Lubomir Rintel" <lkundrak@v3.sk>,
	imv4bel@gmail.com
Subject: Re: [PATCH] pcmcia: synclink_cs: Fix use-after-free in mgslpc_ioctl()
Date: Thu, 15 Sep 2022 22:03:33 -0700	[thread overview]
Message-ID: <20220916050333.GA188358@ubuntu> (raw)
In-Reply-To: <YyLcG1hG5d6D4zNN@owl.dominikbrodowski.net>

The previous mailing list is here:
https://lore.kernel.org/lkml/20220913052020.GA85241@ubuntu/#r


Dear all,


I reported that the scr24x_cs driver does not cause UAF, which is incorrect.

UAFs can also occur in the scr24x_cs driver in the following order:
```
                cpu0                                                cpu1
       1. open()
                                                             2. scr24x_remove()
                                                                device_destroy()
                                                                cdev_del()
                                                                kref_put()
       3. scr24x_open()
          kref_get()   <- refcount_t: addition on 0;
                                                             4. scr24x_delete()
                                                                kfree(dev);
       5. scr24x_read()    <- UAF
```
Because this driver uses kref_init, it looks as if no UAF is happening, but it does.

Since there is no lock between .open and .remove, kref_get() is called after kref_put() 
is called, so "refcount_t: addition on 0;" This is what happens.


So I submitted a patch for all drivers in this path:
- synclink_cs.c "v2" patch : https://lore.kernel.org/lkml/20220916045734.GA187909@ubuntu/T/#u
- cm4040_cs.c : https://lore.kernel.org/lkml/20220916045834.GA188033@ubuntu/T/#u
- cm4000_cs.c : https://lore.kernel.org/lkml/20220916045929.GA188153@ubuntu/T/#u
- scr24x_cs.c : https://lore.kernel.org/lkml/20220916050006.GA188273@ubuntu/T/#u


Best Regards,
Hyunwoo Kim.

  parent reply	other threads:[~2022-09-16  5:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13  5:20 [PATCH] pcmcia: synclink_cs: Fix use-after-free in mgslpc_ioctl() Hyunwoo Kim
2022-09-13 14:59 ` Arnd Bergmann
2022-09-13 15:14   ` Paul Fulghum
2022-09-13 15:43     ` Hyunwoo Kim
2022-09-15  2:08   ` Hyunwoo Kim
2022-09-15  7:35     ` Arnd Bergmann
2022-09-15  8:02       ` Dominik Brodowski
2022-09-15  9:00         ` Hyunwoo Kim
2022-09-16  5:03         ` Hyunwoo Kim [this message]
2022-09-15 14:05       ` Harald Welte

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=20220916050333.GA188358@ubuntu \
    --to=imv4bel@gmail.com \
    --cc=akpm@osdl.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=laforge@gnumonks.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=lkundrak@v3.sk \
    --cc=paulkf@microgate.com \
    /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.