[PATCH v3 0/2] tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
From: Rustam Mustafin
Date: Tue Nov 24 2026 - 09:24:43 EST
io_uring passes its own file offset to the TPM character devices despite
nonseekable_open(), and its asynchronous requests do not fit the single
command and response per open file. Patch 1 rejects io_uring and AIO with
-EIO. Patch 2 adds the selftest and replaces the separate selftest
patch [1].
The series applies on top of "tpm: Track the response read position
internally" [2].
preadv2() and pwritev2() with RWF_SYNC, RWF_DSYNC, RWF_APPEND or
RWF_NOAPPEND now succeed and ignore the flag, instead of failing with
-EOPNOTSUPP.
Tested with swtpm in QEMU: the tpm2 selftests pass, and the new one fails
without patch 1.
Changes in v3:
- squash the selftest into this series, SPDX GPL-2.0-only (Jarkko)
- keep tpm_common_read_iter() and tpm_common_write_iter() non-static:
like tpm_common_read() and tpm_common_write(), they are used in
tpm-dev.c and tpmrm-dev.c (Jarkko)
Changes in v2:
- open the message with the use case, rewrap (Jarkko)
- drop the CONFIG_IO_URING guards (Jarkko)
- drop Suggested-by
[1] https://lore.kernel.org/all/20261123165638.2161305-1-rmustafin@xxxxxxxxxxxxxx/
[2] https://lore.kernel.org/all/20261120121614.978396-2-rmustafin@xxxxxxxxxxxxxx/
v2: https://lore.kernel.org/all/20261123173321.2363162-1-rmustafin@xxxxxxxxxxxxxx/
v1: https://lore.kernel.org/all/20261120142116.1630010-1-rmustafin@xxxxxxxxxxxxxx/
Rustam Mustafin (2):
tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
selftests: tpm2: test that io_uring reads are rejected
drivers/char/tpm/tpm-dev-common.c | 70 +++++++++++++++++++++
drivers/char/tpm/tpm-dev.c | 2 +
drivers/char/tpm/tpm-dev.h | 2 +
drivers/char/tpm/tpmrm-dev.c | 2 +
tools/testing/selftests/tpm2/Makefile | 2 +-
tools/testing/selftests/tpm2/test_uring.sh | 15 +++++
tools/testing/selftests/tpm2/tpm2_tests.py | 72 ++++++++++++++++++++++
7 files changed, 164 insertions(+), 1 deletion(-)
create mode 100755 tools/testing/selftests/tpm2/test_uring.sh
--
2.52.0