public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Nazar Mokrynskyi <nazar@mokrynskyi.com>,
	linux-media@vger.kernel.org, linux-usb@vger.kernel.org,
	linux@roeck-us.net, Tomasz Figa <tfiga@chromium.org>
Subject: Re: [Bug 216543] kernel NULL pointer dereference usb_hcd_alloc_bandwidth
Date: Wed, 19 Oct 2022 11:08:28 -0400	[thread overview]
Message-ID: <Y1AS7DzY+Vo8ovUx@rowland.harvard.edu> (raw)
In-Reply-To: <CANiDSCvnWpnw=+QHMfykdbocUyZ2JgN0Mpyvq+fu9u4XWoqwwA@mail.gmail.com>

On Wed, Oct 19, 2022 at 01:22:48PM +0900, Ricardo Ribalda wrote:
> Hi Laurent
> 
> On Wed, 19 Oct 2022 at 10:45, Laurent Pinchart
> <laurent.pinchart@ideasonboard.com> wrote:
> > And I would like to avoid having to roll out manual changes to all
> > drivers when the problem can be fixed in the core, just because nobody
> > can be bothered to spend time to implement a good fix. We don't have to
> > aim for a solution at the cdev level if that takes too long, an
> > implementation in V4L2 would be enough to start with.
> 
> Do we know what a "good fix" would look like?. This is a race
> condition between cdev, v4l2, and usb_driver. The only entity that
> knows about the three of them is the driver.
> 
> If we "fix" v4l2 to provide a callback to notify the framework about a
> "bus disconnect". It can prevent new syscalls, but it cannot interrupt
> the current ones.

It doesn't need to interrupt current syscalls.  It merely needs to wait 
until the current ones complete (and help them to complete early by 
making them aware of the disconnection) and to prevent new ones from 
starting.

I have no idea what facility (if any) the framework uses for this 
already.  However, if it turns out that proper synchronization needs a 
new approach, I suggest trying SRCU.  It can be viewed in some respects 
as a kind of read-write mutex that is highly optimized for rapid 
read-locks and -unlocks at the cost of very slow write-locks -- 
appropriate here since every syscall would need a read-lock whereas 
write-locking would be needed only when a disconnect occurs.

Alan Stern

  reply	other threads:[~2022-10-19 16:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-216543-208809@https.bugzilla.kernel.org/>
     [not found] ` <bug-216543-208809-AR52CPrAl3@https.bugzilla.kernel.org/>
2022-10-17 21:25   ` [Bug 216543] kernel NULL pointer dereference usb_hcd_alloc_bandwidth Alan Stern
2022-10-18  5:40     ` Ricardo Ribalda
2022-10-18  5:42       ` Ricardo Ribalda
2022-10-18 14:46       ` Alan Stern
2022-10-18 15:02       ` Laurent Pinchart
2022-10-19  1:35         ` Ricardo Ribalda
2022-10-19  1:44           ` Laurent Pinchart
2022-10-19  4:22             ` Ricardo Ribalda
2022-10-19 15:08               ` Alan Stern [this message]
2022-10-20  0:57                 ` Ricardo Ribalda
2022-10-20 14:25                   ` Alan Stern

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=Y1AS7DzY+Vo8ovUx@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=nazar@mokrynskyi.com \
    --cc=ribalda@chromium.org \
    --cc=tfiga@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox