tee: amdtee: fix race condition in amdtee_open_session
stable inclusion from stable-v5.10.177 commit f632a90f8e39db39b322107b9a8d438b826a7f4f category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I88YNP Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f632a90f8e39db39b322107b9a8d438b826a7f4f -------------------------------- commit f8502fba upstream. There is a potential race condition in amdtee_open_session that may lead to use-after-free. For instance, in amdtee_open_session() after sess->sess_mask is set, and before setting: sess->session_info[i] = session_info; if amdtee_close_session() closes this same session, then 'sess' data structure will be released, causing kernel panic when 'sess' is accessed within amdtee_open_session(). The solution is to set the bit sess->sess_mask as the last step in amdtee_open_session(). Fixes: 757cc3e9 ("tee: add AMD-TEE driver") Cc: stable@vger.kernel.org Signed-off-by:Rijo Thomas <Rijo-john.Thomas@amd.com> Acked-by:
Sumit Garg <sumit.garg@linaro.org> Signed-off-by:
Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by:
Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by:
sanglipeng <sanglipeng1@jd.com> (cherry picked from commit 9c4e003d)
Loading
Please sign in to comment