]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit39bed040af67728e5adba95f780310434fe5950f
tree2f77ada52e80adab6f8963e2e7b21bcad45bde94
parent5437906a10e9fd0aa94e6b8d9be156a0a078c83a
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: cbe877863373 ("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