accel/habanalabs: fix information leak in sec_attest_info()
authorXingyuan Mo <hdthky0@gmail.com>
Fri, 8 Dec 2023 13:00:59 +0000 (21:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:38 +0000 (15:35 -0800)
commit975aaaddc226303d382baa0d0ece84e8bec1fcf5
treefd21d3c793c93b8c9e1dd602660a2fc518c7957f
parent5ada13fb677068d7ae59f5a1d062c073a6a0917c
accel/habanalabs: fix information leak in sec_attest_info()

[ Upstream commit a9f07790a4b2250f0140e9a61c7f842fd9b618c7 ]

This function may copy the pad0 field of struct hl_info_sec_attest to user
mode which has not been initialized, resulting in leakage of kernel heap
data to user mode. To prevent this, use kzalloc() to allocate and zero out
the buffer, which can also eliminate other uninitialized holes, if any.

Fixes: 0c88760f8f5e ("habanalabs/gaudi2: add secured attestation info uapi")
Signed-off-by: Xingyuan Mo <hdthky0@gmail.com>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/accel/habanalabs/common/habanalabs_ioctl.c