Page MenuHomeFreeBSD

mtw: fix zero-length queue array that can corrupt struct mtw_softc
ClosedPublic

Authored by markj on Mon, Aug 17, 7:22 PM.
Tags
None
Referenced Files
F167483089: D58897.diff
Sat, Aug 22, 3:43 AM
F167394794: D58897.id184213.diff
Fri, Aug 21, 12:57 PM
F167392317: D58897.id184552.diff
Fri, Aug 21, 12:40 PM
F167392160: D58897.diff
Fri, Aug 21, 12:39 PM
Subscribers

Details

Summary

The mtw softc declares sc_epq with MTW_BULK_RX even though MTW_BULK_RX is enum
value 0, while initialization and queue handling index up to MTW_EP_QUEUES;
attaching a matching USB WLAN device can drive writes past the absent array and
corrupt adjacent softc fields.

This suggested patch sizes sc_epq with MTW_EP_QUEUES so the softc contains the
endpoint queues the driver initializes and uses.

Fixes: c14b01624261 ("mt7601U: Importing if_mtw from OpenBSD")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Mon, Aug 17, 7:22 PM
bz added subscribers: adrian, bz.

I'll accept this for the queue index problem; looking through the driver it feels like something else got convoluted but I could be wrong on that. @jsm and @adrian should probably cross-check that.

This revision is now accepted and ready to land.Mon, Aug 17, 8:30 PM

Perhaps also check https://reviews.freebsd.org/D50174 I never committed it because it seemed to get device time outs on aarch64 (rpi4 in my test)

In D58897#1352929, @jsm wrote:

Perhaps also check https://reviews.freebsd.org/D50174 I never committed it because it seemed to get device time outs on aarch64 (rpi4 in my test)

I don't have any hardware to test this with, this is a patch that was submitted to secteam. It's clearly "right" since otherwise sc_epq is an array of length 0, and today it works by accident probably because most of the fields following the array are copy+pasted from somewhere and don't actually get used.