Commit e8f75c02 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'x86_sgx_for_v6.5' of git://git.kernel.org/pub/scm/linux/kernel/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()
parents 12dc0100 1e327963
...@@ -755,6 +755,7 @@ static void sgx_mmu_notifier_release(struct mmu_notifier *mn, ...@@ -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 *encl_mm = container_of(mn, struct sgx_encl_mm, mmu_notifier);
struct sgx_encl_mm *tmp = NULL; struct sgx_encl_mm *tmp = NULL;
bool found = false;
/* /*
* The enclave itself can remove encl_mm. Note, objects can't be moved * The enclave itself can remove encl_mm. Note, objects can't be moved
...@@ -764,12 +765,13 @@ static void sgx_mmu_notifier_release(struct mmu_notifier *mn, ...@@ -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) { list_for_each_entry(tmp, &encl_mm->encl->mm_list, list) {
if (tmp == encl_mm) { if (tmp == encl_mm) {
list_del_rcu(&encl_mm->list); list_del_rcu(&encl_mm->list);
found = true;
break; break;
} }
} }
spin_unlock(&encl_mm->encl->mm_lock); spin_unlock(&encl_mm->encl->mm_lock);
if (tmp == encl_mm) { if (found) {
synchronize_srcu(&encl_mm->encl->srcu); synchronize_srcu(&encl_mm->encl->srcu);
mmu_notifier_put(mn); mmu_notifier_put(mn);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment