All of lore.kernel.org
 help / color / mirror / Atom feed
From: xqx12 <s2exqx@gmail.com>
To: gregkh@linuxfoundation.org, jslaby@suse.cz
Cc: linux-kernel@vger.kernel.org, chyyuu@gmail.com,
	xuyongjiande@gmail.com, xqx12 <xiaoqixue_1@163.com>
Subject: [PATCH] tty: an overflow of multiplication in drivers/tty/cyclades.c
Date: Wed, 18 Dec 2013 09:00:29 +0800	[thread overview]
Message-ID: <1387328429-15172-1-git-send-email-xiaoqixue_1@163.com> (raw)

there is an overflow in the code :
cyz_polling_cycle = (arg * HZ) / 1000,
the multiplicator arg comes from user, so it may be an overflow if
arg is a big number. And the value of cyc_polling_cycle will be
wrong when it is used next time.

Reported-by: Qixue Xiao <xiaoqixue_1@163.com>
Suggested-by: Yongjian Xu <xuyongjiande@gmail.com>
Suggested-by: Yu Chen <chyyuu@gmail.com>
Signed-off-by: Qixue Xiao <xiaoqixue_1@163.com>
---
 drivers/tty/cyclades.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 33f83fe..a57bb5a 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -2709,6 +2709,8 @@ cy_ioctl(struct tty_struct *tty,
 		break;
 #ifndef CONFIG_CYZ_INTR
 	case CYZSETPOLLCYCLE:
+		if (arg > LONG_MAX / HZ)
+			return -ENODEV;
 		cyz_polling_cycle = (arg * HZ) / 1000;
 		break;
 	case CYZGETPOLLCYCLE:
-- 
1.7.9.5


             reply	other threads:[~2013-12-18  1:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18  1:00 xqx12 [this message]
2013-12-19  0:57 ` [PATCH] tty: an overflow of multiplication in drivers/tty/cyclades.c Greg KH
2013-12-19 10:12   ` xiaoqixue_1
  -- strict thread matches above, loose matches on Subject: below --
2013-12-20  9:49 Qixue Xiao
2013-12-16 14:21 xqx12
2013-12-17 17:39 ` Greg KH

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=1387328429-15172-1-git-send-email-xiaoqixue_1@163.com \
    --to=s2exqx@gmail.com \
    --cc=chyyuu@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiaoqixue_1@163.com \
    --cc=xuyongjiande@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.