Commit 1c143821 authored by Dan Carpenter's avatar Dan Carpenter Committed by Ben Hutchings

bna: integer overflow bug in debugfs

commit 13e2d518 upstream.

We could allocate less memory than intended because we do:

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

The shift can overflow leading to a crash.  This is debugfs code so the
impact is very small.

Fixes: 7afc5dbd ("bna: Add debugfs interface.")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarRasesh Mody <rasesh.mody@cavium.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent a89905a9
...@@ -331,7 +331,7 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf, ...@@ -331,7 +331,7 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *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) {
pr_warn("bna %s: Failed to read user buffer\n", pr_warn("bna %s: Failed to read user buffer\n",
pci_name(bnad->pcidev)); pci_name(bnad->pcidev));
kfree(kern_buf); kfree(kern_buf);
......
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