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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Aug 2018 16:14:43 +0000 (18:14 +0200)
commit27250cf83def3eeff4e438571a0aa9c18deb898f
tree6bb1644bc0f4f84faf74abf1610065e337941b52
parent5ee45fc998a3e45af45f8886fb13cc417c6f18d0
IB/ocrdma: fix out of bounds access to local buffer

commit 062d0f22a30c39840ea49b72cfcfc1aa4cc538fa upstream.

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>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/ocrdma/ocrdma_stats.c