Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb vhci(4): Don't fail with ENOBUFS if no intrxfer ...



details:   https://anonhg.NetBSD.org/src/rev/04162f95b027
branches:  trunk
changeset: 363428:04162f95b027
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Mar 12 15:30:42 2022 +0000

description:
vhci(4): Don't fail with ENOBUFS if no intrxfer is set up.

uhub(4) will set up the intrxfer and query the current state at its
leisure -- no need to treat racing with it as a failure.

(If there's some reason the caller needs to know about this state,
then (a) there should be a comment explaining why, and (b) the
assertion in vhci_fd_close needs to change.)

Should fix a host of syzbot crashes that were all tripping over the
same assertion but with different gobbledegook on the console --
here's all the ones I found in a quick skim of the front page:

Reported-by: syzbot+58b183ac688d656e1bfd%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+e7b0e904184aa2c18224%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+476b25a0a3655f3565d6%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+e5b69892daf87a7464f2%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+db7f0bc71c33a488d0fc%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+71d0e82df292c56739da%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+dbfaad061b2c909d6332%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+d8b90cead59b887fee64%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+ea147adc4461acb9f491%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+cb7239776d4f51c39ca3%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+ffbae2dd4d4a0196b026%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+95d4852ea931f775cf35%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+3236a5e1bc356909b322%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+f5ac32d58eab38bce263%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+beb9643da72188117748%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+896191203695ba350566%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+7c175b48b2682cc329a5%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+caa5bc391d36d75335ea%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+9fe6d4c43fa10f9e4dfa%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+ae9ae663386e72d171b3%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+a0c3a5c2f7af91e44c17%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+3c157b017d0cafa7aea9%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+1e05efbbf2d7df821bfd%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+999f20b408f61e22f4e0%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+22d227370f78b3a34442%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+33760fa9b95349460293%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+75d865aafbc9ebadb0f6%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+3ddff5cb80bc0c9ac635%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+0f942570160d533d892d%syzkaller.appspotmail.com@localhost

diffstat:

 sys/dev/usb/vhci.c |  12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diffs (61 lines):

diff -r 8e6fc60484cc -r 04162f95b027 sys/dev/usb/vhci.c
--- a/sys/dev/usb/vhci.c        Sat Mar 12 15:29:17 2022 +0000
+++ b/sys/dev/usb/vhci.c        Sat Mar 12 15:30:42 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vhci.c,v 1.25 2022/03/03 06:12:11 riastradh Exp $ */
+/*     $NetBSD: vhci.c,v 1.26 2022/03/12 15:30:42 riastradh Exp $ */
 
 /*
  * Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.25 2022/03/03 06:12:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.26 2022/03/12 15:30:42 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -787,7 +787,6 @@
        vhci_port_t *port;
        struct usbd_xfer *xfer;
        u_char *p;
-       int ret = 0;
 
        port = &sc->sc_port[vfd->port];
 
@@ -802,7 +801,6 @@
        xfer = sc->sc_intrxfer;
 
        if (xfer == NULL) {
-               ret = ENOBUFS;
                goto done;
        }
        KASSERT(xfer->ux_status == USBD_IN_PROGRESS);
@@ -821,7 +819,7 @@
 
 done:
        mutex_exit(&sc->sc_lock);
-       return ret;
+       return 0;
 }
 
 static void
@@ -886,8 +884,7 @@
 
        xfer = sc->sc_intrxfer;
        if (xfer == NULL) {
-               mutex_exit(&sc->sc_lock);
-               return ENOBUFS;
+               goto done;
        }
        KASSERT(xfer->ux_status == USBD_IN_PROGRESS);
 
@@ -910,6 +907,7 @@
        vhci_port_flush(sc, port);
 
        mutex_exit(&port->lock);
+done:
        mutex_exit(&sc->sc_lock);
        return 0;
 }



Home | Main Index | Thread Index | Old Index