summaryrefslogtreecommitdiffstats
path: root/include/uapi/misc
diff options
context:
space:
mode:
authorTomer Tayar <ttayar@habana.ai>2022-05-22 09:43:54 +0300
committerOded Gabbay <ogabbay@kernel.org>2022-07-12 09:09:22 +0300
commit41021f728a91035997f1ad3d6d4e983711f3c483 (patch)
tree45c37cc3528c877c967dd2effc914b651dbcd9b2 /include/uapi/misc
parent2bc61bc4f3eadc967f8540ef48f2085198b24db8 (diff)
downloadlinux-41021f728a91035997f1ad3d6d4e983711f3c483.tar.gz
linux-41021f728a91035997f1ad3d6d4e983711f3c483.tar.bz2
linux-41021f728a91035997f1ad3d6d4e983711f3c483.zip
habanalabs: fix race between hl_get_compute_ctx() and hl_ctx_put()
hl_get_compute_ctx() is used to get the pointer to the compute context from the hpriv object. The function is called in code paths that are not necessarily initiated by user, so it is possible that a context release process will happen in parallel. This can lead to a race condition in which hl_get_compute_ctx() retrieves the context pointer, and just before it increments the context refcount, the context object is released and a freed memory is accessed. To avoid this race, add a mutex to protect the context pointer in hpriv. With this lock, hl_get_compute_ctx() will be able to detect if the context has been released or is about to be released. struct hl_ctx_mgr has a mutex for contexts IDR with a similar "ctx_lock" name, so rename it to just "lock" to avoid a confusion with the new lock. Signed-off-by: Tomer Tayar <ttayar@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'include/uapi/misc')
0 files changed, 0 insertions, 0 deletions