Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1322377

[patch] USB: cxacru: fix an bounds check warning

From Dan Carpenter <dan.carpenter@oracle.com>
Newsgroups linux.kernel
Subject [patch] USB: cxacru: fix an bounds check warning
Date 2016-01-30 15:40 +0100
Message-ID <qWEQW-4yb-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


This is a privileged operation so it doesn't matter much.  We use "tmp"
as an offset into an array.  If it were invalid we could read out of
bounds and trigger an oops if the memory is not mapped.  Plus it makes
static checkers complain.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This changes the behavior a little bit because in the original we could
give slightly invalid "len" values and the function would still work...

Please review it extra carefully to make sure it doesn't break
userspace.

diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 1173f9c..0a866e9 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -476,6 +476,8 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
 			return -EINVAL;
 		if (index < 0 || index > 0x7f)
 			return -EINVAL;
+		if (tmp < 0 || tmp > len - pos)
+			return -EINVAL;
 		pos += tmp;
 
 		/* skip trailing newline */

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[patch] USB: cxacru: fix an bounds check warning Dan Carpenter <dan.carpenter@oracle.com> - 2016-01-30 15:40 +0100

csiph-web