From: Michael Mera Date: Mon, 1 May 2017 06:41:16 +0000 (+0900) Subject: IB/ocrdma: fix out of bounds access to local buffer X-Git-Tag: MMI-PSA29.97-13-9~5649^3~21 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=062d0f22a30c39840ea49b72cfcfc1aa4cc538fa;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git 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 Reviewed-by: Leon Romanovsky Signed-off-by: Doug Ledford --- diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c index f8e4b0a6486f..66056f9a9700 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c +++ b/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_dev *dev = pstats->dev; - if (count > 32) + if (*ppos != 0 || count == 0 || count > sizeof(tmp_str)) goto err; if (copy_from_user(tmp_str, buffer, count))