From nobody Tue Jul 23 13:19:35 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 4WSyRW3J22z5Rwrs; Tue, 23 Jul 2024 13:19:35 +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 4WSyRW2DK7z4HyD; Tue, 23 Jul 2024 13:19:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721740775; 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=d/OjInUEY2RocD7YTqE6sh0mLepnIBWukR11EPRdcOw=; b=fNITH3/y2tA6/E63719ohnB6ccmrdZq9JXugXyelKFeY9gTLE56a+8ayC6W5cZ0KURhTOq 5Nn93PAr0HGw4rb1ApXzC0l00XU6OKWj5hrPMKnCR0wXTrkBxt61M0O7SQfUkifkXemdG1 0DA8XG7ZV1RzKFCDZzbsTQWI0QWX3xZfkobnXqEhM4sPAatxbwYLFmlhKFNgassL0H2y2p 91x7Fa0XKR8sTz+kLLIQhLtzqIiKUvIssWP1SbkvjAVe1wzcPiaka3tzwqure9YJ0B6fjS bVwzndstEi+wUsSfcikg+VzKMwkyKXJl7bL+lrDypaIeDH75FP9VVhPvm+G8oQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721740775; a=rsa-sha256; cv=none; b=KALZsIuHZ7Av5Ij3xwtAYuc6raIxuIK6nEVg2EoETMNOop4yDs+Wz1H8qyfs8wi7dyZZW+ JqJ8j/4G4bH9KSpHqcDJoroHqDborqsrrNvjDUpNoDNt+tQq6Eu086sI391qTAoFyguUWg 9uvsTuc8xEQrAQAzokeQta0qgri82u7tqgpY+736GE2DHQdxDf1SOi5QvGkums+7HIiR8M Vb688aOISId8n7R5cLcy9djaskjtNKFSB6e+uYSGN1jVPSbfpg6suh7jg02AwuitFNq4JX U/h6hZ/vWRRQOJJ4+2O0HjZMmtC8wX9kfIJpTyjNjGmQlfXGh6VL7P6XzQQK9w== 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=1721740775; 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=d/OjInUEY2RocD7YTqE6sh0mLepnIBWukR11EPRdcOw=; b=MlL8EEkNZNLKrR1j1urLD016bFanZHIlFVmb6wu4zcKt+i+9JPWvJ1OLS0F7kuLkSyybc9 6w62EfMQy/L4n6tOB5ZcVb9dubCoGdMAlu/tEeK9uO5OiCBqR3Myw4GR8WosSextKGa8xv f9M71zer3dV9NAMr/IFa7UWE4MLebGYOmsf3T3CUDP0Sj07HwYUiSqQRmtnqzqA7vjY9Jj nfprfvZ+ZSm8kLWbejbAvXcu+sb8whM7EwDFe8l7q2z6zDU23YaDuZcqkmKsQMs4sVOHYc fpM4h0FKLl4YZ0fuCgWpEQZmUEDhCAU53R88DC5bc4sQNpZ7uJKPbMPcq4jC0A== 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 4WSyRW1FG4zTcP; Tue, 23 Jul 2024 13:19:35 +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 46NDJZ8K004436; Tue, 23 Jul 2024 13:19:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46NDJZMG004433; Tue, 23 Jul 2024 13:19:35 GMT (envelope-from git) Date: Tue, 23 Jul 2024 13:19:35 GMT Message-Id: <202407231319.46NDJZMG004433@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 030cbcc4c231 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 030cbcc4c231be94b5ded668930e5be17cb9d3d5 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=030cbcc4c231be94b5ded668930e5be17cb9d3d5 commit 030cbcc4c231be94b5ded668930e5be17cb9d3d5 Author: Mark Johnston AuthorDate: 2024-07-09 14:10:45 +0000 Commit: Mark Johnston CommitDate: 2024-07-23 13:01:37 +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 (cherry picked from commit 5dc4682c32691b9d0a20abdc5479d6ce2b36915e) --- 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");