public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: sunkbd - fix UAF in sunkbd_reinit()
Date: Tue, 17 Nov 2020 12:10:34 -0800	[thread overview]
Message-ID: <20201117201034.GA2009714@dtor-ws> (raw)
In-Reply-To: <20201117132751.14863-1-yangyingliang@huawei.com>

Hi Yang,

On Tue, Nov 17, 2020 at 09:27:51PM +0800, Yang Yingliang wrote:
> 
> After sunkbd->tq is added to workqueue, before scheduled work finish, sunkbd is
> freed by sunkbd_disconnect(), when sunkbd is used in sunkbd_reinit(), it causes
> a UAF. Fix this by calling flush_scheduled_work() before free sunkbd.
> 
> This fixes CVE-2020-25669.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/input/keyboard/sunkbd.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
> index 27126e621eb6..b6222896acdf 100644
> --- a/drivers/input/keyboard/sunkbd.c
> +++ b/drivers/input/keyboard/sunkbd.c
> @@ -316,6 +316,7 @@ static void sunkbd_disconnect(struct serio *serio)
>  {
>  	struct sunkbd *sunkbd = serio_get_drvdata(serio);
>  
> +	flush_scheduled_work();

This is unfortunately racy as we may get interrupt and reschedule the
work again before we get to disabling the port.

It is properly fixed by 77e70d351db7de07a46ac49b87a6c3c7a60fca7e.

>  	sunkbd_enable(sunkbd, false);
>  	input_unregister_device(sunkbd->dev);
>  	serio_close(serio);
> -- 
> 2.17.1
> 

Thanks.

-- 
Dmitry

      reply	other threads:[~2020-11-17 20:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17 13:27 [PATCH] Input: sunkbd - fix UAF in sunkbd_reinit() Yang Yingliang
2020-11-17 20:10 ` Dmitry Torokhov [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=20201117201034.GA2009714@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yangyingliang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox