[Bug 285039] uhso_mux_intr_callback() should check mux against sc->sc_ttys

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 25 Feb 2025 18:33:29 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=285039

            Bug ID: 285039
           Summary: uhso_mux_intr_callback() should check mux against
                    sc->sc_ttys
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: usb
          Assignee: usb@FreeBSD.org
          Reporter: rtm@lcs.mit.edu

In sys/dev/usb/net/uhso.c's uhso_mux_intr_callback():

                i = *((unsigned char *)res.buffer);
                mux = 0;
                while (i >>= 1) {
                        mux++;
                }
                ...;
                if (mux > UHSO_MPORT_TYPE_NOMAX)
                        break;
                ...;
                usbd_xfer_set_priv(
                    sc->sc_tty[mux].ht_xfer[UHSO_CTRL_READ],
                    &sc->sc_tty[mux]);

UHSO_MPORT_TYPE_NOMAX is 8, but uhso_alloc_tty() might have allocated
fewer than 8 slots for sc->sc_tty. So uhso_mux_intr_callback() should
also check mux against sc->sc_ttys (the real size of sc_tty).
Otherwise it can pass a pointer pulled from invalid memory as the
first argument to usbd_xfer_set_priv(), which writes through that
pointer.

-- 
You are receiving this mail because:
You are the assignee for the bug.