From nobody Tue Jul 09 14:33:02 2024 X-Original-To: dev-commits-src-all@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 4WJNkk6ppjz5QVxG; Tue, 09 Jul 2024 14:33:02 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WJNkk5vp0z4PGJ; Tue, 9 Jul 2024 14:33:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720535582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tUqa9h0WZSJMEdxPmyaxKoPM9B3SU0KImnlHOe0fL4I=; b=q7RMJSDVx+kHgUvHjh9I/Ldu6HHcAVwcsb+eDr/yeqXkTbP/xU05d/YC77AB62qfIkapUy MskkQzRY1pC/7RZZbHbF6vWEHibEjtwrLeSuCAN79U4uORlNOKkca1bzK4Yn0qqfLTRZHm rOBK6xgyRvl5hyObXHfGIBgQi6iPzjki2Jt/iIdRel+F+S1jmdoHevM8AJzT9492YJ4ArY 9e6TyXkkTDx9bTa1UVkLrdnJ5tEKgkOtKofveuSuxKUkvd6R16vIhKOplu6idXUEANWC8S mCTNQ8tKT+KZ8i/qWsLnHK0bqYPiYoDXUdBvNEtYvNrLUMCzc5V61vP+vXgn4A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720535582; a=rsa-sha256; cv=none; b=BtbevC4mAEp/WpjHNiSKnfi4TWXQeW72Hugd3w+VIt+7VlNJFJlYT7mR/eCp/oCt4p9C5i GeuMvjomI7VRJUEs2o+XGvgKbJFGUZxNgaIUKw8zgWxgjpkPiSSfS3W4noTplVapw1b6+b fCgd4sa7zWeebcEe1S53hd4I8MYe1M8K+Vn2F6rTScrZPfMN8ztYKKph8DE2GfcvQSNNUL 62KRO47W4E8YsGF/ToMtAarVhweMnr+iAIFdj0GbHyIFXEW7sjCcQ+1grDw/UreWe1C+jT rCEtaRb52hNkXfrrFJuYv4Uac+parP6pN5ISDSCtt9VHv5srpiFL4lWvbfgdEA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720535582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tUqa9h0WZSJMEdxPmyaxKoPM9B3SU0KImnlHOe0fL4I=; b=yju6F5dXsqzjJjACVJvwZh26GQw46wsgz6IEakZmeLAN0jmWMnjI/DlkhMonJyqmWgPZVa OrVXDwbJIfxncfDcaBCZ4/P8dUBhW0FDabYTJ/CvwE+dbvADAorQaovjQZSvm4FAJI2TrN LI/YnY7mDLwb2M5KacS5wQqV0x4/ci9vKeMmO0/rEJWknsqAdDyc0VBhifB2NNRnpkgBbH Se8UO9bTXw1EypWs08Gtpud9+pwPD+FlBN98I+YQeR0jOL1qfavx+AjL0rWkorEm2jWY19 al82AhennZkPt/5J2Zxfm5PoXAd7D7Q3EiHBSqGK012kzbc5yQgWQ1AaP8OXUw== 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 4WJNkk5WJ2zf0n; Tue, 9 Jul 2024 14:33:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 469EX2tZ063431; Tue, 9 Jul 2024 14:33:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 469EX2XU063428; Tue, 9 Jul 2024 14:33:02 GMT (envelope-from git) Date: Tue, 9 Jul 2024 14:33:02 GMT Message-Id: <202407091433.469EX2XU063428@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 5dc4682c3269 - main - if_urndis: Organize buffer layouts more naturally List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5dc4682c32691b9d0a20abdc5479d6ce2b36915e Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5dc4682c32691b9d0a20abdc5479d6ce2b36915e commit 5dc4682c32691b9d0a20abdc5479d6ce2b36915e Author: Mark Johnston AuthorDate: 2024-07-09 14:10:45 +0000 Commit: Mark Johnston CommitDate: 2024-07-09 14:26:16 +0000 if_urndis: Organize buffer layouts more naturally - Group the request header and I/O buffer in one structure, rather than assuming that both request structures have the same size. - Pass a pointer to the whole structure to urndis_ctrl_query() and urndis_ctrl_set() rather than just the header. Otherwise, on CHERI platforms, these functions violate subobject bounds since they modify the buffer following the header. While here, there is no apparent reason for the request structure used in urndis_attach() to be allocated statically. Change it so that it's allocated on the stack. No functional change intended. Reviewed by: jhb MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D45866 --- sys/dev/usb/net/if_urndis.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/dev/usb/net/if_urndis.c b/sys/dev/usb/net/if_urndis.c index 824609aa869f..0a7cb3fed953 100644 --- a/sys/dev/usb/net/if_urndis.c +++ b/sys/dev/usb/net/if_urndis.c @@ -214,15 +214,15 @@ urndis_attach_post(struct usb_ether *ue) static int urndis_attach(device_t dev) { - static struct { - union { + union { + struct { struct rndis_query_req query; + uint8_t addr[ETHER_ADDR_LEN]; + } eaddr; + struct { struct rndis_set_req set; - } hdr; - union { - uint8_t eaddr[ETHER_ADDR_LEN]; uint32_t filter; - } ibuf; + } filter; } msg; struct urndis_softc *sc = device_get_softc(dev); struct usb_ether *ue = &sc->sc_ue; @@ -278,10 +278,10 @@ urndis_attach(device_t dev) } /* Determine MAC address */ - memset(msg.ibuf.eaddr, 0, sizeof(msg.ibuf.eaddr)); + memset(msg.eaddr.addr, 0, sizeof(msg.eaddr.addr)); URNDIS_LOCK(sc); error = urndis_ctrl_query(sc, OID_802_3_PERMANENT_ADDRESS, - &msg.hdr.query, sizeof(msg.hdr.query) + sizeof(msg.ibuf.eaddr), + (struct rndis_query_req *)&msg.eaddr, sizeof(msg.eaddr), &buf, &bufsz); URNDIS_UNLOCK(sc); if (error != (int)RNDIS_STATUS_SUCCESS) { @@ -297,10 +297,10 @@ urndis_attach(device_t dev) /* Initialize packet filter */ sc->sc_filter = NDIS_PACKET_TYPE_BROADCAST | NDIS_PACKET_TYPE_ALL_MULTICAST; - msg.ibuf.filter = htole32(sc->sc_filter); + msg.filter.filter = htole32(sc->sc_filter); URNDIS_LOCK(sc); error = urndis_ctrl_set(sc, OID_GEN_CURRENT_PACKET_FILTER, - &msg.hdr.set, sizeof(msg.hdr.set) + sizeof(msg.ibuf.filter)); + (struct rndis_set_req *)&msg.filter, sizeof(msg.filter)); URNDIS_UNLOCK(sc); if (error != (int)RNDIS_STATUS_SUCCESS) { device_printf(dev, "Unable to set data filters\n"); @@ -641,7 +641,7 @@ urndis_ctrl_handle_reset(struct urndis_softc *sc, msg_filter.filter = htole32(sc->sc_filter); rval = urndis_ctrl_set(sc, OID_GEN_CURRENT_PACKET_FILTER, - &msg_filter.hdr, sizeof(msg_filter)); + (struct rndis_set_req *)&msg_filter, sizeof(msg_filter)); if (rval != RNDIS_STATUS_SUCCESS) { DPRINTF("unable to reset data filters\n");