Date: Mon, 28 Dec 2020 12:52:48 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 59ded046d5ed - stable/11 - MFC r368658: Improve handling of alternate settings in the USB stack. Message-ID: <202012281252.0BSCqmuE012709@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/11 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=59ded046d5ed159b334337166dc5dd0509531d1c commit 59ded046d5ed159b334337166dc5dd0509531d1c Author: Hans Petter Selasky <hselasky@FreeBSD.org> AuthorDate: 2020-12-15 11:51:17 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> CommitDate: 2020-12-28 12:51:31 +0000 MFC r368658: Improve handling of alternate settings in the USB stack. Limit the number of alternate settings to 256. Else the alternate index variable may wrap around. PR: 251856 Submitted by: Ma, Horse <Shichun.Ma@dell.com> Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/dev/usb/usb_parse.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/usb_parse.c b/sys/dev/usb/usb_parse.c index 07446966fccf..e90973120626 100644 --- a/sys/dev/usb/usb_parse.c +++ b/sys/dev/usb/usb_parse.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2008-2020 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -139,8 +139,20 @@ usb_idesc_foreach(struct usb_config_descriptor *cd, break; if ((id->bDescriptorType == UDESC_INTERFACE) && (id->bLength >= sizeof(*id))) { - if (ps->iface_no_last == id->bInterfaceNumber) + if (ps->iface_no_last == id->bInterfaceNumber) { + /* + * Don't allow more than 256 alternate + * settings to avoid overflowing the + * alternate index which is a 8-bit + * variable. + */ + if (ps->iface_index_alt == 255) { + DPRINTF("Interface(%u) has more than 256 alternate settings\n", + id->bInterfaceNumber); + continue; + } new_iface = 0; + } ps->iface_no_last = id->bInterfaceNumber; break; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202012281252.0BSCqmuE012709>