* [PATCH] bna: integer overflow bug in debugfs
@ 2017-03-17 20:52 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2017-03-17 20:52 UTC (permalink / raw)
To: Rasesh Mody, Krishna Gudipati
Cc: Sudarsana Kalluru, Dept-GELinuxNICDev, netdev, kernel-janitors
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>
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;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] bna: integer overflow bug in debugfs
@ 2017-03-17 20:52 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2017-03-17 20:52 UTC (permalink / raw)
To: Rasesh Mody, Krishna Gudipati
Cc: Sudarsana Kalluru, Dept-GELinuxNICDev, netdev, kernel-janitors
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>
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;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH] bna: integer overflow bug in debugfs
2017-03-17 20:52 ` Dan Carpenter
(?)
@ 2017-03-21 1:14 ` Mody, Rasesh
-1 siblings, 0 replies; 5+ messages in thread
From: Mody, Rasesh @ 2017-03-21 1:14 UTC (permalink / raw)
To: Dan Carpenter, Krishna Gudipati
Cc: Kalluru, Sudarsana, Dept-GE Linux NIC Dev, netdev, kernel-janitors
> From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> Sent: Friday, March 17, 2017 1:53 PM
>
> 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>
>
> 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;
You are correct, thanks Dan for adding the check.
Acked-by: Rasesh Mody <rasesh.mody@cavium.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bna: integer overflow bug in debugfs
2017-03-17 20:52 ` Dan Carpenter
@ 2017-03-22 0:43 ` David Miller
-1 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-03-22 0:43 UTC (permalink / raw)
To: dan.carpenter
Cc: rasesh.mody, kgudipat, sudarsana.kalluru, Dept-GELinuxNICDev,
netdev, kernel-janitors
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Fri, 17 Mar 2017 23:52:35 +0300
> 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>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bna: integer overflow bug in debugfs
@ 2017-03-22 0:43 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-03-22 0:43 UTC (permalink / raw)
To: dan.carpenter
Cc: rasesh.mody, kgudipat, sudarsana.kalluru, Dept-GELinuxNICDev,
netdev, kernel-janitors
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Fri, 17 Mar 2017 23:52:35 +0300
> 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>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-03-22 0:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 20:52 [PATCH] bna: integer overflow bug in debugfs Dan Carpenter
2017-03-17 20:52 ` Dan Carpenter
2017-03-21 1:14 ` Mody, Rasesh
2017-03-22 0:43 ` David Miller
2017-03-22 0:43 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.