]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
IB/ocrdma: fix out of bounds access to local buffer
authorMichael Mera <dev@michaelmera.com>
Mon, 1 May 2017 06:41:16 +0000 (15:41 +0900)
committerDoug Ledford <dledford@redhat.com>
Mon, 1 May 2017 19:04:23 +0000 (15:04 -0400)
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>
drivers/infiniband/hw/ocrdma/ocrdma_stats.c

index f8e4b0a6486f44f7bf540644e6910abc024cad63..66056f9a9700ab733b9f6ec24847d36427b9ec26 100644 (file)
@@ -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))