Commit 3e351275 authored by Dan Carpenter's avatar Dan Carpenter Committed by Martin K. Petersen

scsi: bfa: integer overflow in debugfs

We could allocate less memory than intended because we do:

	bfad->regdata = kzalloc(len << 2, GFP_KERNEL);

The shift can overflow leading to a crash.  This is debugfs code so the
impact is very small.  I fixed the network version of this in March with
commit 13e2d518 ("bna: integer overflow bug in debugfs").

Fixes: ab2a9ba1 ("[SCSI] bfa: add debugfs support")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 22698483
...@@ -255,7 +255,8 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf, ...@@ -255,7 +255,8 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
struct bfad_s *bfad = port->bfad; struct bfad_s *bfad = port->bfad;
struct bfa_s *bfa = &bfad->bfa; struct bfa_s *bfa = &bfad->bfa;
struct bfa_ioc_s *ioc = &bfa->ioc; struct bfa_ioc_s *ioc = &bfa->ioc;
int addr, len, rc, i; int addr, rc, i;
u32 len;
u32 *regbuf; u32 *regbuf;
void __iomem *rb, *reg_addr; void __iomem *rb, *reg_addr;
unsigned long flags; unsigned long flags;
...@@ -266,7 +267,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf, ...@@ -266,7 +267,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
return PTR_ERR(kern_buf); return PTR_ERR(kern_buf);
rc = sscanf(kern_buf, "%x:%x", &addr, &len); rc = sscanf(kern_buf, "%x:%x", &addr, &len);
if (rc < 2) { if (rc < 2 || len > (UINT_MAX >> 2)) {
printk(KERN_INFO printk(KERN_INFO
"bfad[%d]: %s failed to read user buf\n", "bfad[%d]: %s failed to read user buf\n",
bfad->inst_no, __func__); bfad->inst_no, __func__);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment