mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Insu Yun <wuninsu@gmail.com>
To: gregkh@linuxfoundation.org, stefan.koch10@gmail.com,
	stern@rowland.harvard.edu, kborer@gmail.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu,
	changwoo@gatech.edu, Insu Yun <wuninsu@gmail.com>
Subject: [PATCH] usb: fix potential integer overflow in usb_sg_init
Date: Mon, 18 Jan 2016 12:06:51 -0500	[thread overview]
Message-ID: <1453136811-15601-1-git-send-email-wuninsu@gmail.com> (raw)

If nents value is sufficient large, e.g 0x40000000, 
then it can overflow size in kmalloc and heap overflow happesns.
Therefore nents value needs to be checked to prevent overflow.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/usb/core/message.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 8e641b5..53393d5 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -367,7 +367,8 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
 	if (!io || !dev || !sg
 			|| usb_pipecontrol(pipe)
 			|| usb_pipeisoc(pipe)
-			|| nents <= 0)
+			|| nents <= 0
+			|| nents >= UINT_MAX / sizeof(*io->urbs))
 		return -EINVAL;
 
 	spin_lock_init(&io->lock);
-- 
1.9.1

             reply	other threads:[~2016-01-18 17:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18 17:06 Insu Yun [this message]
2016-01-18 18:32 ` Alan Stern
     [not found] <CAGoFzNevhCgsSqNc_Sga1Y9Xdo3WP+AnQPk9FY9Msx+PjLmUQA@mail.gmail.com>
2016-01-19 14:57 ` Alan Stern
     [not found] <CAGoFzNfFhxgFP7L9hL84qqASRGVtv5MYF8AtmvZs4sEBhEVzcg@mail.gmail.com>
2016-01-19 22:04 ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453136811-15601-1-git-send-email-wuninsu@gmail.com \
    --to=wuninsu@gmail.com \
    --cc=changwoo@gatech.edu \
    --cc=gregkh@linuxfoundation.org \
    --cc=insu@gatech.edu \
    --cc=kborer@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stefan.koch10@gmail.com \
    --cc=stern@rowland.harvard.edu \
    --cc=taesoo@gatech.edu \
    --cc=yeongjin.jang@gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®