]> git.baikalelectronics.ru Git - kernel.git/commit
NTB: ntb_tool: uninitialized heap data in tool_fn_write()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 20 Jul 2022 18:28:18 +0000 (21:28 +0300)
committerJon Mason <jdmason@kudzu.us>
Tue, 9 Aug 2022 15:54:41 +0000 (11:54 -0400)
commit334267cf5be8650f8928cb65e03ed5d3663254be
tree40208c34f31e95d8b8c0d2a9b68e1f84328a2c87
parent54f9b65ccc666d7fc504891fe96de9ee63ad7c4d
NTB: ntb_tool: uninitialized heap data in tool_fn_write()

The call to:

ret = simple_write_to_buffer(buf, size, offp, ubuf, size);

will return success if it is able to write even one byte to "buf".
The value of "*offp" controls which byte.  This could result in
reading uninitialized data when we do the sscanf() on the next line.

This code is not really desigined to handle partial writes where
*offp is non-zero and the "buf" is preserved and re-used between writes.
Just ban partial writes and replace the simple_write_to_buffer() with
copy_from_user().

Fixes: db02d0f4731d ("NTB: Add tool test client")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
drivers/ntb/test/ntb_tool.c