linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: core: limit access to rawdescriptors which were not allocated
@ 2020-08-25 16:16 yanfei.xu
  2020-08-25 17:56 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: yanfei.xu @ 2020-08-25 16:16 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-kernel

From: Yanfei Xu <yanfei.xu@windriver.com>

When using systemcall to read the rawdescriptors, make sure we won't
access to the rawdescriptors never allocated, which are number
exceed the USB_MAXCONFIG.

Reported-by: syzbot+256e56ddde8b8957eabd@syzkaller.appspotmail.com
Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
---
 drivers/usb/core/sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index a2ca38e25e0c..1a7a625e5f55 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -895,7 +895,8 @@ read_descriptors(struct file *filp, struct kobject *kobj,
 	 * configurations (config plus subsidiary descriptors).
 	 */
 	for (cfgno = -1; cfgno < udev->descriptor.bNumConfigurations &&
-			nleft > 0; ++cfgno) {
+			nleft > 0 &&
+			cfgno < USB_MAXCONFIG; ++cfgno) {
 		if (cfgno < 0) {
 			src = &udev->descriptor;
 			srclen = sizeof(struct usb_device_descriptor);
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-26  6:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25 16:16 [PATCH] USB: core: limit access to rawdescriptors which were not allocated yanfei.xu
2020-08-25 17:56 ` kernel test robot
2020-08-25 18:00 ` Alan Stern
2020-08-26  6:56   ` Xu, Yanfei
2020-08-25 21:35 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).