* [patch] bfa: integer overflow bug in debugfs
@ 2015-10-19 10:17 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2015-10-19 10:17 UTC (permalink / raw)
To: Anil Gurumurthy
Cc: Sudarsana Kalluru, James E.J. Bottomley, linux-scsi,
kernel-janitors
The "len << 2" operation can have an integer overflow and leading to a
kernel crash. This is debugfs and thus root only so no one really
cares, but we should fix it anyway just to make the static checker
happy.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
index 74a307c..d5832b1 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -254,7 +254,8 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
struct bfad_s *bfad = port->bfad;
struct bfa_s *bfa = &bfad->bfa;
struct bfa_ioc_s *ioc = &bfa->ioc;
- int addr, len, rc, i;
+ unsigned int len;
+ int addr, rc, i;
u32 *regbuf;
void __iomem *rb, *reg_addr;
unsigned long flags;
@@ -265,7 +266,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
return PTR_ERR(kern_buf);
rc = sscanf(kern_buf, "%x:%x", &addr, &len);
- if (rc < 2) {
+ if (rc < 2 || len > UINT_MAX >> 2) {
printk(KERN_INFO
"bfad[%d]: %s failed to read user buf\n",
bfad->inst_no, __func__);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-10-19 10:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 10:17 [patch] bfa: integer overflow bug in debugfs Dan Carpenter
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).