linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Hyunwoo Kim <imv4bel@gmail.com>, steve.glendinning@shawell.net
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] video: fbdev: smscufx: Fix use-after-free in ufx_ops_open()
Date: Sun, 25 Sep 2022 13:57:46 +0200	[thread overview]
Message-ID: <dcccfc86-1bfe-e37a-fa6f-28a159e35f14@gmx.de> (raw)
In-Reply-To: <20220925110329.GA380036@ubuntu>

On 9/25/22 13:03, Hyunwoo Kim wrote:
> A race condition may occur if the user physically removes the
> USB device while calling open() for this device node.
>
> This is a race condition between the ufx_ops_open() function and
> the ufx_usb_disconnect() function, which may eventually result in UAF.
>
> So, add a mutex to the ufx_ops_open() and ufx_usb_disconnect() functions
> to avoid race contidion of krefs.
>
> Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
> ---
>   drivers/video/fbdev/smscufx.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
> index d7aa5511c361..a4378a7241f7 100644
> --- a/drivers/video/fbdev/smscufx.c
> +++ b/drivers/video/fbdev/smscufx.c
> @@ -1065,6 +1067,8 @@ static int ufx_ops_open(struct fb_info *info, int user)
>   {
>   	struct ufx_data *dev = info->par;
>
> +	mutex_lock(&disconnect_mutex);
> +

The next few lines show:
         if (user == 0 && !console)
                 return -EBUSY;

in this case this function exits with the mutex held.

Please check all possible exit paths and unlock the mutex
where necessary.

Helge

  reply	other threads:[~2022-09-25 11:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 11:03 [PATCH] video: fbdev: smscufx: Fix use-after-free in ufx_ops_open() Hyunwoo Kim
2022-09-25 11:57 ` Helge Deller [this message]
2022-09-25 12:34   ` Hyunwoo Kim

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=dcccfc86-1bfe-e37a-fa6f-28a159e35f14@gmx.de \
    --to=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imv4bel@gmail.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=steve.glendinning@shawell.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).