Browse Source

IB/ocrdma: fix out of bounds access to local buffer

In write to debugfs file 'resource_stats' the local buffer 'tmp_str' is
written at index 'count-1' where 'count' is the size of the write, so
potentially 0.

This patch filters odd values for the write size/position to avoid this
type of problem.

Signed-off-by: Michael Mera <dev@michaelmera.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Michael Mera 8 years ago
parent
commit
062d0f22a3
1 changed files with 1 additions and 1 deletions
  1. 1 1
      drivers/infiniband/hw/ocrdma/ocrdma_stats.c

+ 1 - 1
drivers/infiniband/hw/ocrdma/ocrdma_stats.c

@@ -643,7 +643,7 @@ static ssize_t ocrdma_dbgfs_ops_write(struct file *filp,
 	struct ocrdma_stats *pstats = filp->private_data;
 	struct ocrdma_stats *pstats = filp->private_data;
 	struct ocrdma_dev *dev = pstats->dev;
 	struct ocrdma_dev *dev = pstats->dev;
 
 
-	if (count > 32)
+	if (*ppos != 0 || count == 0 || count > sizeof(tmp_str))
 		goto err;
 		goto err;
 
 
 	if (copy_from_user(tmp_str, buffer, count))
 	if (copy_from_user(tmp_str, buffer, count))