On Sun, Sep 12, 2021 at 12:53:30PM -0400, Mitchell Riedstra wrote:
>
> > I have reverted the commit by now. Could you please send me the dmesg
> > and ssh-agent FIDO_DEBUG=1 output with and without this commit
> > applied.
> >
>
> Sure! See attached.
Thanks, the diff below should hopefully work as it corrects a regression
introduced in uhidev_attach(). However, I'm not still convinced that
this is a good idea.
Index: dev/usb/ucc.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ucc.c,v
retrieving revision 1.26
diff -u -p -r1.26 ucc.c
--- dev/usb/ucc.c 12 Sep 2021 06:58:08 -0000 1.26
+++ dev/usb/ucc.c 13 Sep 2021 05:09:13 -0000
@@ -633,9 +633,9 @@ ucc_match(struct device *parent, void *m
void *desc;
int size;
- uhidev_get_report_desc(uha->parent, &desc, &size);
- if (hid_report_size(desc, size, hid_input, uha->reportid) == 0)
+ if (uha->isize == 0)
return UMATCH_NONE;
+ uhidev_get_report_desc(uha->parent, &desc, &size);
if (!ucc_hid_match(desc, size, uha->reportid))
return UMATCH_NONE;
@@ -648,7 +648,7 @@ ucc_attach(struct device *parent, struct
struct ucc_softc *sc = (struct ucc_softc *)self;
struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
void *desc;
- int error, repid, size;
+ int error, size;
sc->sc_mode = WSKBD_TRANSLATED;
sc->sc_last_translate = -1;
@@ -659,10 +659,9 @@ ucc_attach(struct device *parent, struct
sc->sc_hdev.sc_report_id = uha->reportid;
uhidev_get_report_desc(uha->parent, &desc, &size);
- repid = uha->reportid;
- sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
- sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
- sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
+ sc->sc_hdev.sc_isize = uha->isize;
+ sc->sc_hdev.sc_osize = uha->osize;
+ sc->sc_hdev.sc_fsize = uha->fsize;
error = ucc_hid_parse(sc, desc, size);
if (error) {
Index: dev/usb/ugold.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ugold.c,v
retrieving revision 1.19
diff -u -p -r1.19 ugold.c
--- dev/usb/ugold.c 12 Sep 2021 06:58:08 -0000 1.19
+++ dev/usb/ugold.c 13 Sep 2021 05:09:14 -0000
@@ -139,7 +139,7 @@ ugold_attach(struct device *parent, stru
{
struct ugold_softc *sc = (struct ugold_softc *)self;
struct uhidev_attach_arg *uha = aux;
- int size, repid;
+ int size;
void *desc;
sc->sc_udev = uha->parent->sc_udev;
@@ -159,10 +159,9 @@ ugold_attach(struct device *parent, stru
}
uhidev_get_report_desc(uha->parent, &desc, &size);
- repid = uha->reportid;
- sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
- sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
- sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
+ sc->sc_hdev.sc_isize = uha->isize;
+ sc->sc_hdev.sc_osize = uha->osize;
+ sc->sc_hdev.sc_fsize = uha->fsize;
if (uhidev_open(&sc->sc_hdev)) {
printf(", unable to open interrupt pipe\n");
Index: dev/usb/uhid.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/uhid.c,v
retrieving revision 1.86
diff -u -p -r1.86 uhid.c
--- dev/usb/uhid.c 12 Sep 2021 06:58:08 -0000 1.86
+++ dev/usb/uhid.c 13 Sep 2021 05:09:14 -0000
@@ -126,19 +126,15 @@ uhid_attach(struct device *parent, struc
{
struct uhid_softc *sc = (struct uhid_softc *)self;
struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
- int size, repid;
- void *desc;
sc->sc_hdev.sc_intr = uhid_intr;
sc->sc_hdev.sc_parent = uha->parent;
sc->sc_hdev.sc_udev = uha->uaa->device;
sc->sc_hdev.sc_report_id = uha->reportid;
- uhidev_get_report_desc(uha->parent, &desc, &size);
- repid = uha->reportid;
- sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
- sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
- sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
+ sc->sc_hdev.sc_isize = uha->isize;
+ sc->sc_hdev.sc_osize = uha->osize;
+ sc->sc_hdev.sc_fsize = uha->fsize;
printf(": input=%d, output=%d, feature=%d\n",
sc->sc_hdev.sc_isize, sc->sc_hdev.sc_osize, sc->sc_hdev.sc_fsize);
Index: dev/usb/uhidev.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/uhidev.c,v
retrieving revision 1.95
diff -u -p -r1.95 uhidev.c
--- dev/usb/uhidev.c 12 Sep 2021 06:58:08 -0000 1.95
+++ dev/usb/uhidev.c 13 Sep 2021 05:09:15 -0000
@@ -252,6 +252,7 @@ uhidev_attach(struct device *parent, str
uha.reportid = UHIDEV_CLAIM_MULTIPLE_REPORTID;
uha.nreports = nrepid;
uha.claimed = malloc(nrepid, M_TEMP, M_WAITOK|M_ZERO);
+ uha.isize = uha.osize = uha.fsize = 0;
/* Look for a driver claiming multiple report IDs first. */
dev = config_found_sm(self, &uha, NULL, uhidevsubmatch);
@@ -273,15 +274,16 @@ uhidev_attach(struct device *parent, str
for (repid = 0; repid < nrepid; repid++) {
DPRINTF(("%s: try repid=%d\n", __func__, repid));
- if (hid_report_size(desc, size, hid_input, repid) == 0 &&
- hid_report_size(desc, size, hid_output, repid) == 0 &&
- hid_report_size(desc, size, hid_feature, repid) == 0)
- continue;
/* Could already be assigned by uhidev_set_report_dev(). */
if (sc->sc_subdevs[repid] != NULL)
continue;
+ uha.isize = hid_report_size(desc, size, hid_input, repid);
+ uha.osize = hid_report_size(desc, size, hid_output, repid);
+ uha.fsize = hid_report_size(desc, size, hid_feature, repid);
+ if (uha.isize == 0 && uha.osize == 0 && uha.osize == 0)
+ continue;
uha.reportid = repid;
dev = config_found_sm(self, &uha, uhidevprint, uhidevsubmatch);
sc->sc_subdevs[repid] = (struct uhidev *)dev;
Index: dev/usb/uhidev.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/uhidev.h,v
retrieving revision 1.32
diff -u -p -r1.32 uhidev.h
--- dev/usb/uhidev.h 12 Sep 2021 06:58:08 -0000 1.32
+++ dev/usb/uhidev.h 13 Sep 2021 05:09:15 -0000
@@ -84,6 +84,9 @@ struct uhidev_attach_arg {
#define UHIDEV_CLAIM_MULTIPLE_REPORTID 255
uint8_t nreports;
uint8_t *claimed;
+ int isize;
+ int osize;
+ int fsize;
};
int uhidev_report_type_conv(int);
Index: dev/usb/ukbd.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ukbd.c,v
retrieving revision 1.84
diff -u -p -r1.84 ukbd.c
--- dev/usb/ukbd.c 12 Sep 2021 06:58:08 -0000 1.84
+++ dev/usb/ukbd.c 13 Sep 2021 05:09:15 -0000
@@ -231,9 +231,9 @@ ukbd_attach(struct device *parent, struc
uhidev_get_report_desc(uha->parent, &desc, &dlen);
repid = uha->reportid;
- sc->sc_hdev.sc_isize = hid_report_size(desc, dlen, hid_input, repid);
- sc->sc_hdev.sc_osize = hid_report_size(desc, dlen, hid_output, repid);
- sc->sc_hdev.sc_fsize = hid_report_size(desc, dlen, hid_feature, repid);
+ sc->sc_hdev.sc_isize = uha->isize;
+ sc->sc_hdev.sc_osize = uha->osize;
+ sc->sc_hdev.sc_fsize = uha->fsize;
/*
* Since the HID-Proxy is always detected before any
Index: dev/usb/ums.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ums.c,v
retrieving revision 1.50
diff -u -p -r1.50 ums.c
--- dev/usb/ums.c 12 Sep 2021 06:58:08 -0000 1.50
+++ dev/usb/ums.c 13 Sep 2021 05:09:15 -0000
@@ -121,7 +121,7 @@ ums_attach(struct device *parent, struct
struct hidms *ms = &sc->sc_ms;
struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
struct usb_attach_arg *uaa = uha->uaa;
- int size, repid;
+ int size;
void *desc;
u_int32_t qflags = 0;
@@ -138,10 +138,9 @@ ums_attach(struct device *parent, struct
if (uaa->vendor == USB_VENDOR_ELECOM)
ums_fix_elecom_descriptor(sc, desc, size, uaa->product);
- repid = uha->reportid;
- sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
- sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
- sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
+ sc->sc_hdev.sc_isize = uha->isize;
+ sc->sc_hdev.sc_osize = uha->osize;
+ sc->sc_hdev.sc_fsize = uha->fsize;
if (sc->sc_quirks & UQ_MS_REVZ)
qflags |= HIDMS_REVZ;
Index: dev/usb/umstc.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/umstc.c,v
retrieving revision 1.6
diff -u -p -r1.6 umstc.c
--- dev/usb/umstc.c 12 Sep 2021 06:58:08 -0000 1.6
+++ dev/usb/umstc.c 13 Sep 2021 05:09:15 -0000
@@ -98,7 +98,7 @@ umstc_attach(struct device *parent, stru
struct umstc_softc *sc = (struct umstc_softc *)self;
struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
struct usb_attach_arg *uaa = uha->uaa;
- int size, repid;
+ int size;
void *desc;
sc->sc_hdev.sc_intr = umstc_intr;
@@ -109,10 +109,9 @@ umstc_attach(struct device *parent, stru
usbd_set_idle(uha->parent->sc_udev, uha->parent->sc_ifaceno, 0, 0);
uhidev_get_report_desc(uha->parent, &desc, &size);
- repid = uha->reportid;
- sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
- sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
- sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
+ sc->sc_hdev.sc_isize = uha->isize;
+ sc->sc_hdev.sc_osize = uha->osize;
+ sc->sc_hdev.sc_fsize = uha->fsize;
uhidev_open(&sc->sc_hdev);
Index: dev/usb/uwacom.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/uwacom.c,v
retrieving revision 1.4
diff -u -p -r1.4 uwacom.c
--- dev/usb/uwacom.c 12 Sep 2021 06:58:08 -0000 1.4
+++ dev/usb/uwacom.c 13 Sep 2021 05:09:15 -0000
@@ -95,7 +95,7 @@ uwacom_attach(struct device *parent, str
struct hidms *ms = &sc->sc_ms;
struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
struct usb_attach_arg *uaa = uha->uaa;
- int size, repid;
+ int size;
void *desc;
sc->sc_hdev.sc_intr = uwacom_intr;
@@ -106,10 +106,9 @@ uwacom_attach(struct device *parent, str
usbd_set_idle(uha->parent->sc_udev, uha->parent->sc_ifaceno, 0, 0);
uhidev_get_report_desc(uha->parent, &desc, &size);
- repid = uha->reportid;
- sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
- sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
- sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
+ sc->sc_hdev.sc_isize = uha->isize;
+ sc->sc_hdev.sc_osize = uha->osize;
+ sc->sc_hdev.sc_fsize = uha->fsize;
ms->sc_device = self;
ms->sc_rawmode = 1;