From: Alan Stern <stern@rowland.harvard.edu>
To: Greg KH <greg@kroah.com>, Pete Zaitcev <zaitcev@redhat.com>
Cc: USB list <linux-usb@vger.kernel.org>
Subject: Re: [PATCH] usb: mon: Fix a deadlock in usbmon between mmap and read
Date: Tue, 26 Nov 2019 10:20:14 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.44L0.1911261018110.1508-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <20191126004407.4b72ef7f@suzdal.zaitcev.lan>
On Tue, 26 Nov 2019, Pete Zaitcev wrote:
> The problem arises because our read() function grabs a lock of the
> circular buffer, finds something of interest, then invokes copy_to_user()
> straight from the buffer, which in turn takes mm->mmap_sem. In the same
> time, the callback mon_bin_vma_fault() is invoked under mm->mmap_sem.
> It attempts to take the fetch lock and deadlocks.
>
> This patch does away with protecting of our page list with any
> semaphores, and instead relies on the kernel not close the device
> while mmap is active in a process.
>
> In addition, we prohibit re-sizing of a buffer while mmap is active.
> This way, when (now unlocked) fault is processed, it works with the
> page that is intended to be mapped-in, and not some other random page.
> Note that this may have an ABI impact, but hopefully no legitimate
> program is this wrong.
>
> Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
> Reported-by: syzbot+56f9673bb4cdcbeb0e92@syzkaller.appspotmail.com
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Also this should have:
Fixes: 46eb14a6e158 ("USB: fix usbmon BUG trigger")
CC: <stable@vger.kernel.org>
Alan Stern
next prev parent reply other threads:[~2019-11-26 15:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-26 6:44 [PATCH] usb: mon: Fix a deadlock in usbmon between mmap and read Pete Zaitcev
2019-11-26 15:20 ` Alan Stern [this message]
2019-11-27 4:35 ` Pete Zaitcev
2019-11-27 6:55 ` Greg KH
2019-11-27 15:07 ` Alan Stern
2019-12-05 2:39 Pete Zaitcev
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=Pine.LNX.4.44L0.1911261018110.1508-100000@iolanthe.rowland.org \
--to=stern@rowland.harvard.edu \
--cc=greg@kroah.com \
--cc=linux-usb@vger.kernel.org \
--cc=zaitcev@redhat.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 NNTP newsgroup(s).