Skip to content

Commit

Permalink
swtpm: cuse: Lock file_ops_lock before reading tpm_running
Browse files Browse the repository at this point in the history
Lock the file_ops_lock before reading the tpm_running variable so that
access to access to it is serialized among all possible threads.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
  • Loading branch information
stefanberger committed Mar 22, 2024
1 parent 08ac269 commit 77c5bf1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/swtpm/cuse_tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,9 @@ static void ptm_ioctl(fuse_req_t req, int cmd, void *arg,
ptm_init *init_p;
TPM_MODIFIER_INDICATOR orig_locality;

/* prevent other threads from writing or doing ioctls */
g_mutex_lock(FILE_OPS_LOCK);

/* some commands have to wait until the worker thread is done */
switch(cmd) {
case PTM_GET_CAPABILITY:
Expand All @@ -1106,9 +1109,6 @@ static void ptm_ioctl(fuse_req_t req, int cmd, void *arg,
break;
}

/* prevent other threads from writing or doing ioctls */
g_mutex_lock(FILE_OPS_LOCK);

switch (cmd) {
case PTM_GET_CAPABILITY:
if (out_bufsz != sizeof(ptm_cap)) {
Expand Down

0 comments on commit 77c5bf1

Please sign in to comment.