Linux Kernel Mentees Archive mirror
 help / color / mirror / Atom feed
From: Mike Isely <isely@isely.net>
To: "Ricardo B. Marliere" <ricardo@marliere.net>
Cc: syzbot+621409285c4156a009b3@syzkaller.appspotmail.com,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-kernel-mentees@lists.linuxfoundation.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH] media: pvrusb2: fix use after free on context disconnection
Date: Sun, 15 Oct 2023 20:49:57 -0500 (CDT)	[thread overview]
Message-ID: <5f652494-1e4f-4965-f9b7-0f2bf05f718f@isely.net> (raw)
In-Reply-To: <20231012230911.48113-2-ricardo@marliere.net>


Acked-by: Mike Isely <isely@pobox.com>

  -Mike

On Thu, 12 Oct 2023, Ricardo B. Marliere wrote:

> Upon module load, a kthread is created targeting the
> pvr2_context_thread_func function, which may call pvr2_context_destroy
> and thus call kfree() on the context object. However, that might happen
> before the usb hub_event handler is able to notify the driver. This
> patch adds a sanity check before the invalid read reported by syzbot,
> within the context disconnection call stack.
> 
> Fixes: e5be15c63804 ("V4L/DVB (7711): pvrusb2: Fix race on module unload")
> Reported-and-tested-by: syzbot+621409285c4156a009b3@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/all/000000000000a02a4205fff8eb92@google.com/
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
> ---
>  drivers/media/usb/pvrusb2/pvrusb2-context.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
> index 14170a5d72b3..1764674de98b 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
> @@ -268,7 +268,8 @@ void pvr2_context_disconnect(struct pvr2_context *mp)
>  {
>  	pvr2_hdw_disconnect(mp->hdw);
>  	mp->disconnect_flag = !0;
> -	pvr2_context_notify(mp);
> +	if (!pvr2_context_shutok())
> +		pvr2_context_notify(mp);
>  }
>  
>  
> 
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

      reply	other threads:[~2023-10-16  1:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 23:09 [PATCH] media: pvrusb2: fix use after free on context disconnection Ricardo B. Marliere
2023-10-16  1:49 ` Mike Isely [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=5f652494-1e4f-4965-f9b7-0f2bf05f718f@isely.net \
    --to=isely@isely.net \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ricardo@marliere.net \
    --cc=syzbot+621409285c4156a009b3@syzkaller.appspotmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).