linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* The usbmon triggers a BUG in ./include/linux/mm.h
@ 2018-01-08 21:46 Pete Zaitcev
  0 siblings, 0 replies; 2+ messages in thread
From: Pete Zaitcev @ 2018-01-08 21:46 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, Greg Kroah-Hartman, linux-mm, linux-usb, zaitcev

Automated tests triggered this by opening usbmon and accessing the
mmap while simultaneously resizing the buffers. This bug was with
us since 2006, because typically applications only size the buffers
once and thus avoid racing. Reported by Kirill A. Shutemov.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
---
 drivers/usb/mon/mon_bin.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index f6ae753ab99b..f932f40302df 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -1004,7 +1004,9 @@ static long mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg
 		break;
 
 	case MON_IOCQ_RING_SIZE:
+		mutex_lock(&rp->fetch_lock);
 		ret = rp->b_size;
+		mutex_unlock(&rp->fetch_lock);
 		break;
 
 	case MON_IOCT_RING_SIZE:
@@ -1231,12 +1233,16 @@ static int mon_bin_vma_fault(struct vm_fault *vmf)
 	unsigned long offset, chunk_idx;
 	struct page *pageptr;
 
+	mutex_lock(&rp->fetch_lock);
 	offset = vmf->pgoff << PAGE_SHIFT;
-	if (offset >= rp->b_size)
+	if (offset >= rp->b_size) {
+		mutex_unlock(&rp->fetch_lock);
 		return VM_FAULT_SIGBUS;
+	}
 	chunk_idx = offset / CHUNK_SIZE;
 	pageptr = rp->b_vec[chunk_idx].pg;
 	get_page(pageptr);
+	mutex_unlock(&rp->fetch_lock);
 	vmf->page = pageptr;
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* The usbmon triggers a BUG in ./include/linux/mm.h
@ 2018-01-09 15:03 Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2018-01-09 15:03 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Kirill A. Shutemov, Andrew Morton, linux-mm, linux-usb

On Mon, Jan 08, 2018 at 03:46:41PM -0600, Pete Zaitcev wrote:
> Automated tests triggered this by opening usbmon and accessing the
> mmap while simultaneously resizing the buffers. This bug was with
> us since 2006, because typically applications only size the buffers
> once and thus avoid racing. Reported by Kirill A. Shutemov.
> 
> Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
> ---
>  drivers/usb/mon/mon_bin.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

You forgot a reported-by line :(

I'll go add it, it's been a while since you submitted a kernel patch,
you must have forgotten :)

thanks,

greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-09 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-09 15:03 The usbmon triggers a BUG in ./include/linux/mm.h Greg Kroah-Hartman
  -- strict thread matches above, loose matches on Subject: below --
2018-01-08 21:46 Pete Zaitcev

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).