Skip to content

Commit d832ccb

Browse files
committed
ALSA: usb-audio: Validate UAC3 power domain descriptors, too
UAC3 power domain descriptors need to be verified with its variable bLength for avoiding the unexpected OOB accesses by malicious firmware, too. Fixes: 9a2fe9b ("ALSA: usb: initial USB Audio Device Class 3.0 support") Reported-and-tested-by: Youngjun Lee <[email protected]> Cc: <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent e26ad67 commit d832ccb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sound/usb/validate.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ static bool validate_uac3_feature_unit(const void *p,
221221
return d->bLength >= sizeof(*d) + 4 + 2;
222222
}
223223

224+
static bool validate_uac3_power_domain_unit(const void *p,
225+
const struct usb_desc_validator *v)
226+
{
227+
const struct uac3_power_domain_descriptor *d = p;
228+
229+
if (d->bLength < sizeof(*d))
230+
return false;
231+
/* baEntities[] + wPDomainDescrStr */
232+
return d->bLength >= sizeof(*d) + d->bNrEntities + 2;
233+
}
234+
224235
static bool validate_midi_out_jack(const void *p,
225236
const struct usb_desc_validator *v)
226237
{
@@ -285,6 +296,7 @@ static const struct usb_desc_validator audio_validators[] = {
285296
struct uac3_clock_multiplier_descriptor),
286297
/* UAC_VERSION_3, UAC3_SAMPLE_RATE_CONVERTER: not implemented yet */
287298
/* UAC_VERSION_3, UAC3_CONNECTORS: not implemented yet */
299+
FUNC(UAC_VERSION_3, UAC3_POWER_DOMAIN, validate_uac3_power_domain_unit),
288300
{ } /* terminator */
289301
};
290302

0 commit comments

Comments
 (0)