]> git.baikalelectronics.ru Git - kernel.git/commit
misc: sgi-gru: fix use-after-free error in gru_set_context_option, gru_fault and...
authorZheng Wang <zyytlz.wz@163.com>
Thu, 10 Nov 2022 03:50:33 +0000 (11:50 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:24 +0000 (11:41 +0100)
commit57687506bd6ba6783b5f2fc325aaf8fa242abdbd
tree6574ae0e6c9d8edfe7834d5b79e27633e85b265f
parent243d2a2af97b94ceee030f752707610b90067933
misc: sgi-gru: fix use-after-free error in gru_set_context_option, gru_fault and gru_handle_user_call_os

[ Upstream commit 2592da70aa15a11e74f6746c3f804c4b07aff7ab ]

In some bad situation, the gts may be freed gru_check_chiplet_assignment.
The call chain can be gru_unload_context->gru_free_gru_context->gts_drop
and kfree finally. However, the caller didn't know if the gts is freed
or not and use it afterwards. This will trigger a Use after Free bug.

Fix it by introducing a return value to see if it's in error path or not.
Free the gts in caller if gru_check_chiplet_assignment check failed.

Fixes: 447b17e5a2c9 ("gru: allow users to specify gru chiplet 2")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Acked-by: Dimitri Sivanich <sivanich@hpe.com>
Link: https://lore.kernel.org/r/20221110035033.19498-1-zyytlz.wz@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/misc/sgi-gru/grufault.c
drivers/misc/sgi-gru/grumain.c
drivers/misc/sgi-gru/grutables.h