Skip to content

Commit

Permalink
nitro_enclaves: Fix race when accessing has_event flag
Browse files Browse the repository at this point in the history
The `has_event` flag is set while holding the `enclave_info_mutex`
mutex. Let's also hold the mutex while reading the flag to avoid races.

Signed-off-by: Costin Lupu <[email protected]>
  • Loading branch information
clupuishere committed Jan 29, 2024
1 parent 001ec4f commit c6d4cb7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/virt/nitro_enclaves/ne_misc_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1645,9 +1645,13 @@ static __poll_t ne_enclave_poll(struct file *file, poll_table *wait)

poll_wait(file, &ne_enclave->eventq, wait);

mutex_lock(&ne_enclave->enclave_info_mutex);

if (ne_enclave->has_event)
mask |= EPOLLHUP;

mutex_unlock(&ne_enclave->enclave_info_mutex);

return mask;
}

Expand Down

0 comments on commit c6d4cb7

Please sign in to comment.