diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-03-17 23:52:35 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-03-21 17:43:16 -0700 |
commit | 13e2d5187f6b965ba3556caedb914baf81b98ed2 (patch) | |
tree | e528165645f358efee4d19771e76ac35e1e607d1 /drivers/net/ethernet/brocade/bna/bnad_debugfs.c | |
parent | 6bd845d1cf98b45c634baacb8381436dad3c2dd0 (diff) |
bna: integer overflow bug in debugfs
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: 7afc5dbde091 ("bna: Add debugfs interface.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Rasesh Mody <rasesh.mody@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/brocade/bna/bnad_debugfs.c')
-rw-r--r-- | drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c index 05c1c1dd7751..cebfe3bd086e 100644 --- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c +++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c @@ -325,7 +325,7 @@ bnad_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) { netdev_warn(bnad->netdev, "failed to read user buffer\n"); kfree(kern_buf); return -EINVAL; |