mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tpm: tpm_vtpm_proxy: Try to disable queued work before flushing it
@ 2026-11-13  0:11 Stefan Berger
  0 siblings, 0 replies; only message in thread
From: Stefan Berger @ 2026-11-13  0:11 UTC (permalink / raw)
  To: linux-integrity, jarkko
  Cc: linux-kernel, syzkaller, jgg, Stefan Berger, fengaojigui88

If an application opens multiple server-side TPM file descriptors using the
ioctl() on /dev/vtpmx and does not close them in the order they were
opened, then the closing of a file descriptor will run into flush_work()
and be blocked there behind other pending and active work. As a
consequence, the currently active work, that is waiting for a response to
its TPM request, will have to wait for the command to time out since its
STATE_OPENED_FLAG will not be reset. To resolve this issue, try to disable
pending work first before flushing it. The disable_work() returns quickly
and unqueues work for most of the closing file descriptors. If it returns
false, then run flush_work(), which makes sure that ongoing work ends,
which also happens quickly since its STATE_OPENED_FLAG was cleared.

Fixes: 6f99612e2500 ("tpm: Proxy driver for supporting multiple emulated TPMs")
Reported-by: fengaojigui88@gmail.com
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
 drivers/char/tpm/tpm_vtpm_proxy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_vtpm_proxy.c b/drivers/char/tpm/tpm_vtpm_proxy.c
index b81fd2a537df..7ca5ddb0d135 100644
--- a/drivers/char/tpm/tpm_vtpm_proxy.c
+++ b/drivers/char/tpm/tpm_vtpm_proxy.c
@@ -467,7 +467,8 @@ static void vtpm_proxy_work(struct work_struct *work)
 static void vtpm_proxy_work_stop(struct proxy_dev *proxy_dev)
 {
 	vtpm_proxy_fops_undo_open(proxy_dev);
-	flush_work(&proxy_dev->work);
+	if (!disable_work(&proxy_dev->work))
+		flush_work(&proxy_dev->work);
 }
 
 /*
-- 
2.56.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-13  0:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13  0:11 [PATCH] tpm: tpm_vtpm_proxy: Try to disable queued work before flushing it Stefan Berger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®