From owner-dev-commits-src-main@freebsd.org Wed May 5 20:59:37 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CC3AC623261; Wed, 5 May 2021 20:59:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fb8Gd5HNnz4kJw; Wed, 5 May 2021 20:59:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A6ABE3AF9; Wed, 5 May 2021 20:59:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 145KxbxU028744; Wed, 5 May 2021 20:59:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 145KxbLf028743; Wed, 5 May 2021 20:59:37 GMT (envelope-from git) Date: Wed, 5 May 2021 20:59:37 GMT Message-Id: <202105052059.145KxbLf028743@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: d61d98f4ed68 - main - Add freebsd32 compat shims for SIOC[GS]DRVSPEC. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d61d98f4ed68c5f6c81586a529057fe51fd50a60 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 May 2021 20:59:37 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d61d98f4ed68c5f6c81586a529057fe51fd50a60 commit d61d98f4ed68c5f6c81586a529057fe51fd50a60 Author: John Baldwin AuthorDate: 2021-05-05 20:58:50 +0000 Commit: John Baldwin CommitDate: 2021-05-05 20:58:50 +0000 Add freebsd32 compat shims for SIOC[GS]DRVSPEC. Reviewed by: brooks, kib Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D29892 --- sys/net/if.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sys/net/if.c b/sys/net/if.c index a3f5a8dc831a..2517c1f7e5bc 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -149,6 +149,15 @@ CTASSERT(sizeof(struct ifreq) == sizeof(struct ifreq32)); CTASSERT(__offsetof(struct ifreq, ifr_ifru) == __offsetof(struct ifreq32, ifr_ifru)); +struct ifdrv32 { + char ifd_name[IFNAMSIZ]; + uint32_t ifd_cmd; + uint32_t ifd_len; + uint32_t ifd_data; +}; +#define SIOCSDRVSPEC32 _IOC_NEWTYPE(SIOCSDRVSPEC, struct ifdrv32) +#define SIOCGDRVSPEC32 _IOC_NEWTYPE(SIOCGDRVSPEC, struct ifdrv32) + struct ifgroupreq32 { char ifgr_name[IFNAMSIZ]; u_int ifgr_len; @@ -2926,11 +2935,13 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td) #ifdef COMPAT_FREEBSD32 union { struct ifconf ifc; + struct ifdrv ifd; struct ifmediareq ifmr; } thunk; caddr_t saved_data; u_long saved_cmd; struct ifconf32 *ifc32; + struct ifdrv32 *ifd32; struct ifmediareq32 *ifmr32; #endif struct ifnet *ifp; @@ -2962,6 +2973,17 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td) data = (caddr_t)&thunk.ifc; cmd = SIOCGIFCONF; break; + case SIOCGDRVSPEC32: + case SIOCSDRVSPEC32: + ifd32 = (struct ifdrv32 *)data; + memcpy(thunk.ifd.ifd_name, ifd32->ifd_name, + sizeof(thunk.ifd.ifd_name)); + thunk.ifd.ifd_cmd = ifd32->ifd_cmd; + thunk.ifd.ifd_len = ifd32->ifd_len; + thunk.ifd.ifd_data = PTRIN(ifd32->ifd_data); + data = (caddr_t)&thunk.ifd; + cmd = _IOC_NEWTYPE(cmd, struct ifdrv); + break; case SIOCGIFMEDIA32: case SIOCGIFXMEDIA32: ifmr32 = (struct ifmediareq32 *)data; @@ -3082,6 +3104,17 @@ out_noref: case SIOCGIFCONF32: ifc32->ifc_len = thunk.ifc.ifc_len; break; + case SIOCGDRVSPEC32: + /* + * SIOCGDRVSPEC is IOWR, but nothing actually touches + * the struct so just assert that ifd_len (the only + * field it might make sense to update) hasn't + * changed. + */ + KASSERT(thunk.ifd.ifd_len == ifd32->ifd_len, + ("ifd_len was updated %u -> %zu", ifd32->ifd_len, + thunk.ifd.ifd_len)); + break; case SIOCGIFMEDIA32: case SIOCGIFXMEDIA32: ifmr32->ifm_current = thunk.ifmr.ifm_current;