]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
tee: amdtee: fix race condition in amdtee_open_session
authorRijo Thomas <Rijo-john.Thomas@amd.com>
Tue, 28 Feb 2023 09:41:20 +0000 (15:11 +0530)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Wed, 17 May 2023 11:33:40 +0000 (13:33 +0200)
commitc30d720085b89c9fa8ec6f4a286b6deadeb7bdbb
treee3c02733c439ffe97033c4deb41fe7e94207fc20
parent927f287d0e501f75fa5d80a2bc40f4ec90105052
tee: amdtee: fix race condition in amdtee_open_session

BugLink: https://bugs.launchpad.net/bugs/2016877
commit f8502fba45bd30e1a6a354d9d898bc99d1a11e6d 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: 757cc3e9ff1d ("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: Paolo Pisati <paolo.pisati@canonical.com>
drivers/tee/amdtee/core.c