From nobody Sat Dec 18 19:08:00 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 25F3318F9F1B for ; Sat, 18 Dec 2021 19:08:09 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JGb3D6xydz4tmr for ; Sat, 18 Dec 2021 19:08:08 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-qt1-x829.google.com with SMTP id z9so6017606qtj.9 for ; Sat, 18 Dec 2021 11:08:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CxYgxTW7J0wKAqFWc/q8+Fv8Z4iS7DLvSGGYob/nHH8=; b=X8VRFlDiOfIeYrlmPsGQRMirv5gjksFiQrqc+sZcK3f6gh28jbKyBvpvqNcEVSZvyh 7qsV30xXGvobHmNXcL2BRmHS7mFZOYbX4vgkkX4d5Y6b5y6gzwrBswymwKE2j0bZdEDh vHAYShNFkbDI2hhRvtjANK2Owk+HSR0NiX6StbPXEr5ScnXn8gOW1aocXWCAgSIyb2uF 0AQGCX1jWBeq25u8SdNzLQ4dIMmCINVhsV922+yUQfV3A/OH66R8KQ3T8/eiabCqXSiv jEfPpE40NgNMYiXJKMJ1sB1K7us3QUE43AO5ZoQCHRFr8VrTiG238nULyYojFF+mQHqE xoZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CxYgxTW7J0wKAqFWc/q8+Fv8Z4iS7DLvSGGYob/nHH8=; b=zBU98U4w3uPRRhPUAS03FNIFF4HeueOXh38xs7f6CBBk52oj7UvPUdzKCZDtSBi3hd rPaF43kfhWdfA7be5aFby8hPCEAY8uzFamau5ilZ7GsgeqlNf8wXICqw97QX8Ug+3stM 9mHVyVqsxkYRDMkJpwPYMnMcq/Uw5cSdZGexc5B1KuoNdYJNvziLXsGMf2NFMcFfJkkf D/9XwLORON1I8qAzosvy+rvh3i7tzV7egWrZ6ZNR4EZ189ZoeuxKMhfg3+Hd6C7Y9uek Q3JHIZRtQrkze4QCOldRipffFEWzBEJUS8yojBl9DHtKnupTFzViEbVKxrGAj2XBmK7O D7uQ== X-Gm-Message-State: AOAM5329UmAYPjOLkkbGn4JxAsXDg4RaH083DqhQEtHkKC+SsnBvC+lc 2vObfvzFGB88njbEHRVPtSa6WQ== X-Google-Smtp-Source: ABdhPJzzbI/0f2i6QAY8zFpDAHR81ldHYyTSxUpFJhgjz6cNrSKNqhLmDtdRZzk0p1+RpL55KC4Lug== X-Received: by 2002:a05:622a:11d5:: with SMTP id n21mr7170885qtk.396.1639854482035; Sat, 18 Dec 2021 11:08:02 -0800 (PST) Received: from mutt-hbsd (pool-100-16-224-136.bltmmd.fios.verizon.net. [100.16.224.136]) by smtp.gmail.com with ESMTPSA id g12sm10053064qtk.69.2021.12.18.11.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Dec 2021 11:08:01 -0800 (PST) Date: Sat, 18 Dec 2021 14:08:00 -0500 From: Shawn Webb To: Brooks Davis Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 45b48cbc2b58 - main - usb: real freebsd32 support for most ioctls Message-ID: <20211218190800.2v7bzacypzhiguvz@mutt-hbsd> X-Operating-System: FreeBSD mutt-hbsd 14.0-CURRENT-HBSD FreeBSD 14.0-CURRENT-HBSD X-PGP-Key: https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/blob/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc References: <202112172128.1BHLSvgR063035@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mej7q4nqvusyqfqy" Content-Disposition: inline In-Reply-To: <202112172128.1BHLSvgR063035@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4JGb3D6xydz4tmr X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N --mej7q4nqvusyqfqy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey Brooks, On Fri, Dec 17, 2021 at 09:28:57PM +0000, Brooks Davis wrote: > The branch main has been updated by brooks: >=20 > URL: https://cgit.FreeBSD.org/src/commit/?id=3D45b48cbc2b5819cd6e3dee3632= d66e55d5d7c101 >=20 > commit 45b48cbc2b5819cd6e3dee3632d66e55d5d7c101 > Author: Brooks Davis > AuthorDate: 2021-12-17 21:28:13 +0000 > Commit: Brooks Davis > CommitDate: 2021-12-17 21:28:13 +0000 >=20 > usb: real freebsd32 support for most ioctls > =20 > Use thunks or alternative access methods to support ioctls without > the COMPAT_32BIT hacks that store pointers in uint64_t's on 32-bit > platforms. This should allow a normal i386 libusb to work. > =20 > On CheriBSD, the sizes of the structs will differ between CheriABI > (the default) and freebsd64 no matter what so we need proper compat > support there. This change paves the way. > =20 > Reviewed by: hselasky, jrtc27 (prior version) > --- > sys/dev/hid/hidraw.c | 93 +++++++++++++++++++++++++++++++-- > sys/dev/usb/input/uhid.c | 25 +++++++-- > sys/dev/usb/input/uhid_snes.c | 26 ++++++++-- > sys/dev/usb/usb_dev.c | 12 +++++ > sys/dev/usb/usb_generic.c | 118 ++++++++++++++++++++++++++++++++++++= ++++++ > sys/dev/usb/usb_ioctl.h | 57 ++++++++++++++++++++ > 6 files changed, 321 insertions(+), 10 deletions(-) >=20 > diff --git a/sys/dev/hid/hidraw.c b/sys/dev/hid/hidraw.c > index e71b2e2c7d5d..f359fe3e7e6f 100644 > --- a/sys/dev/hid/hidraw.c > +++ b/sys/dev/hid/hidraw.c > @@ -41,6 +41,9 @@ __FBSDID("$FreeBSD$"); > #include "opt_hid.h" > =20 > #include > +#ifdef COMPAT_FREEBSD32 > +#include > +#endif > #include > #include > #include > @@ -115,6 +118,31 @@ struct hidraw_softc { > struct cdev *dev; > }; > =20 > +#ifdef COMPAT_FREEBSD32 > +struct hidraw_gen_descriptor32 { > + uint32_t hgd_data; /* void * */ > + uint16_t hgd_lang_id; > + uint16_t hgd_maxlen; > + uint16_t hgd_actlen; > + uint16_t hgd_offset; > + uint8_t hgd_config_index; > + uint8_t hgd_string_index; > + uint8_t hgd_iface_index; > + uint8_t hgd_altif_index; > + uint8_t hgd_endpt_index; > + uint8_t hgd_report_type; > + uint8_t reserved[8]; > +}; > +#define HIDRAW_GET_REPORT_DESC32 \ > + _IOC_NEWTYPE(HIDRAW_GET_REPORT_DESC, struct hidraw_gen_descriptor32) > +#define HIDRAW_GET_REPORT32 \ > + _IOC_NEWTYPE(HIDRAW_GET_REPORT, struct hidraw_gen_descriptor32) > +#define HIDRAW_SET_REPORT_DESC32 \ > + _IOC_NEWTYPE(HIDRAW_SET_REPORT_DESC, struct hidraw_gen_descriptor32) > +#define HIDRAW_SET_REPORT32 \ > + _IOC_NEWTYPE(HIDRAW_SET_REPORT, struct hidraw_gen_descriptor32) > +#endif > + > static d_open_t hidraw_open; > static d_read_t hidraw_read; > static d_write_t hidraw_write; > @@ -507,11 +535,35 @@ hidraw_write(struct cdev *dev, struct uio *uio, int= flag) > return (error); > } > =20 > +#ifdef COMPAT_FREEBSD32 > +static void > +update_hgd32(const struct hidraw_gen_descriptor *hgd, > + struct hidraw_gen_descriptor32 *hgd32) > +{ > + /* Don't update hgd_data pointer */ > + CP(*hgd, *hgd32, hgd_lang_id); > + CP(*hgd, *hgd32, hgd_maxlen); > + CP(*hgd, *hgd32, hgd_actlen); > + CP(*hgd, *hgd32, hgd_offset); > + CP(*hgd, *hgd32, hgd_config_index); > + CP(*hgd, *hgd32, hgd_string_index); > + CP(*hgd, *hgd32, hgd_iface_index); > + CP(*hgd, *hgd32, hgd_altif_index); > + CP(*hgd, *hgd32, hgd_endpt_index); > + CP(*hgd, *hgd32, hgd_report_type); > + /* Don't update reserved */ > +} > +#endif > + > static int > hidraw_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, > struct thread *td) > { > uint8_t local_buf[HIDRAW_LOCAL_BUFSIZE]; > +#ifdef COMPAT_FREEBSD32 > + struct hidraw_gen_descriptor local_hgd; > + struct hidraw_gen_descriptor32 *hgd32 =3D NULL; > +#endif > void *buf; > struct hidraw_softc *sc; > struct hidraw_gen_descriptor *hgd; > @@ -527,6 +579,32 @@ hidraw_ioctl(struct cdev *dev, u_long cmd, caddr_t a= ddr, int flag, > if (sc =3D=3D NULL) > return (EIO); > =20 > +#ifdef COMPAT_FREEBSD32 > + hgd =3D (struct hidraw_gen_descriptor *)addr; > + switch (cmd) { > + case HIDRAW_GET_REPORT_DESC32: > + case HIDRAW_GET_REPORT32: > + case HIDRAW_SET_REPORT_DESC32: > + case HIDRAW_SET_REPORT32: > + cmd =3D _IOC_NEWTYPE(cmd, struct hidraw_gen_descriptor); > + hgd32 =3D (struct hidraw_gen_descriptor32 *)addr; > + hgd =3D &local_hgd; > + PTRIN_CP(*hgd32, *hgd, hgd_data); > + CP(*hgd32, *hgd, hgd_lang_id); > + CP(*hgd32, *hgd, hgd_maxlen); > + CP(*hgd32, *hgd, hgd_actlen); > + CP(*hgd32, *hgd, hgd_offset); > + CP(*hgd32, *hgd, hgd_config_index); > + CP(*hgd32, *hgd, hgd_string_index); > + CP(*hgd32, *hgd, hgd_iface_index); > + CP(*hgd32, *hgd, hgd_altif_index); > + CP(*hgd32, *hgd, hgd_endpt_index); > + CP(*hgd32, *hgd, hgd_report_type); > + /* Don't copy reserved */ > + break; > + } > +#endif > + It appears this broke building on arm64 when COMPAT_FREEBSD32 is disabled: cc -target aarch64-unknown-freebsd14.0 --sysroot=3D/usr/obj/usr/src/arm64.a= arch64/tmp -B/usr/obj/usr/src/arm64.aarch64/tmp/usr/bin -O2 -pipe -fno-com= mon -DHARDE NEDBSD -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -DKLD_TIED -nos= tdinc -DHAVE_KERNEL_OPTION_HEADERS -include /usr/obj/usr/src/arm64.aarch6= 4/sys/HAR DENEDBSD/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include = -fno-common -g -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fPIC -= fdebug-pr efix-map=3D./machine=3D/usr/src/sys/arm64/include -I/usr/obj/usr/src/arm64.= aarch64/sys/HARDENEDBSD -mstack-protector-guard=3Dsysreg -mstack-protecto= r-guard-reg=3Dsp_ el0 -mstack-protector-guard-offset=3D0 -MD -MF.depend.hidraw.o -MThidraw.= o -mgeneral-regs-only -ffixed-x18 -ffreestanding -fwrapv -fstack-protector = -Wall -Wred undant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpo= inter-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=3D__freebsd_= kprintf__ - Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-e= rror=3Dtautological-compare -Wno-error=3Dempty-body -Wno-error=3Dparenthese= s-equality -Wno -error=3Dunused-function -Wno-error=3Dpointer-sign -Wno-error=3Dshift-negat= ive-value -Wno-address-of-packed-member -Wno-error=3Dunused-but-set-variabl= e -Wno-format-zer o-length -std=3Diso9899:1999 -c /usr/src/sys/dev/hid/hidraw.c -o hidraw= =2Eo /usr/src/sys/dev/hid/hidraw.c:643:27: error: variable 'hgd' is uninitialize= d when used here [-Werror,-Wuninitialized] if (sc->sc_rdesc->len > hgd->hgd_maxlen) { ^~~ /usr/src/sys/dev/hid/hidraw.c:569:35: note: initialize the variable 'hgd' t= o silence this warning struct hidraw_gen_descriptor *hgd; Thanks, --=20 Shawn Webb Cofounder / Security Engineer HardenedBSD https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/03A= 4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc --mej7q4nqvusyqfqy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEA6TL67gupaZ9nzhT/y5nonf44foFAmG+MYoACgkQ/y5nonf4 4fom5A/+PMnbuLxFngYIX5Vo0pzGDUM1Zw+Hx2XoSjOZyFSTi2fwiEqHRQH2yuEi AmqkG/+jt6mNEMX987Djs0jQO+yWgUWi50jRXdbECHdt9/yUQFv61CPSSdBJWcZs UWoyDMH8n0C6t7FPRhnpQgkleP5Wg6Z/KIe/fH/rkiLWn7U4Kqp3GTbhTf55G3Zn Vqdh/XS5vSjP1GxnE0knQZ5kP5xbJ83B0ZtizwqfTgfQRBsL7j7nLpFZXdiH1H3f 22heTZ+oxACSaL6uWjU5b8QaHuDetIUbWPVL1ZuwZzvELFwnCJImAOezPJwCjjR4 Qvopivb7mGKw6AvBc5PBKInaWGfqA9W7/fxq4dy/n5u1rrGzyYeJFG8hlVFBRFo6 mZv6dfJVdmrl/qSIhTCmONmV4yGDmNSM+/VBbpjcjwv3IWtd4/FNTCWLTMRlx+u6 xbPoBnwafJaGkId43QjTV2bz12qjwG0b1XUmBLPUDrk/wxpo0D3w8G8Va1lYKMqi 6ajhI0vgZMgVo82IdkzpkhW+q4apm9MthtHgdFGRVymFKhpwuc+S1QT9EXmocS8k 7rGFceeausKNKIo5pwf6Fnri3pitdmpJM0BC9hcEbJU6qzrPuCkFgusPU9A8IRzf yp2/LxXTuDMBW5cnwmhYFGORety/X2d4bVxtfgpN7aCIWoxbVfo= =wU97 -----END PGP SIGNATURE----- --mej7q4nqvusyqfqy--