NTB: ntb_tool: uninitialized heap data in tool_fn_write()
stable inclusion from stable-v5.10.138 commit 76f3b97e56c69fc6ebce492a825befd311e57c4d category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I60QFD Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=76f3b97e56c69fc6ebce492a825befd311e57c4d -------------------------------- commit 45e1058b upstream. 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: 578b881b ("NTB: Add tool test client") Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com> Signed-off-by: NJon Mason <jdmason@kudzu.us> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com> Reviewed-by: NWei Li <liwei391@huawei.com>
Showing
想要评论请 注册 或 登录