mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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)
This commit is contained in:
parent
b14a491283
commit
030cbcc4c2
1 changed files with 11 additions and 11 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue