OSDN Git Service

octeontx2-af: debugfs: don't corrupt user memory
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 17 Nov 2021 07:34:54 +0000 (10:34 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 18 Nov 2021 04:25:40 +0000 (20:25 -0800)
commita280ef90af01dc133d0a52387e563015686d6294
tree2f77ada52e80adab6f8963e2e7b21bcad45bde94
parent48b71a9e66c2eab60564b1b1c85f4928ed04e406
octeontx2-af: debugfs: don't corrupt user memory

The user supplies the "count" value to say how big its read buffer is.
The rvu_dbg_lmtst_map_table_display() function does not take the "count"
into account but instead just copies the whole table, potentially
corrupting the user's data.

Introduce the "ret" variable to store how many bytes we can copy.  Also
I changed the type of "off" to size_t to make using min() simpler.

Fixes: 0daa55d033b0 ("octeontx2-af: cn10k: debugfs for dumping LMTST map table")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20211117073454.GD5237@kili
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c