Skip to content

Commit

Permalink
Merge tag 'x86_sgx_for_v6.5' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/tip/tip

Pull SGX update from Borislav Petkov:

 - A fix to avoid using a list iterator variable after the loop it is
   used in

* tag 'x86_sgx_for_v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/sgx: Avoid using iterator after loop in sgx_mmu_notifier_release()
  • Loading branch information
torvalds committed Jun 27, 2023
2 parents 12dc010 + 1e32796 commit e8f75c0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/x86/kernel/cpu/sgx/encl.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ static void sgx_mmu_notifier_release(struct mmu_notifier *mn,
{
struct sgx_encl_mm *encl_mm = container_of(mn, struct sgx_encl_mm, mmu_notifier);
struct sgx_encl_mm *tmp = NULL;
bool found = false;

/*
* The enclave itself can remove encl_mm. Note, objects can't be moved
Expand All @@ -764,12 +765,13 @@ static void sgx_mmu_notifier_release(struct mmu_notifier *mn,
list_for_each_entry(tmp, &encl_mm->encl->mm_list, list) {
if (tmp == encl_mm) {
list_del_rcu(&encl_mm->list);
found = true;
break;
}
}
spin_unlock(&encl_mm->encl->mm_lock);

if (tmp == encl_mm) {
if (found) {
synchronize_srcu(&encl_mm->encl->srcu);
mmu_notifier_put(mn);
}
Expand Down

0 comments on commit e8f75c0

Please sign in to comment.