Skip to content

Commit b4cf187

Browse files
Dan Carpentergregkh
authored andcommitted
bna: integer overflow bug in debugfs
[ Upstream commit 13e2d51 ] 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: 7afc5db ("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> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b3f662c commit b4cf187

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/net/ethernet/brocade/bna/bnad_debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
325325
return PTR_ERR(kern_buf);
326326

327327
rc = sscanf(kern_buf, "%x:%x", &addr, &len);
328-
if (rc < 2) {
328+
if (rc < 2 || len > UINT_MAX >> 2) {
329329
netdev_warn(bnad->netdev, "failed to read user buffer\n");
330330
kfree(kern_buf);
331331
return -EINVAL;

0 commit comments

Comments
 (0)