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/[email protected]/
[2] 
https://lore.kernel.org/all/[email protected]/
v2: 
https://lore.kernel.org/all/[email protected]/
v1: 
https://lore.kernel.org/all/[email protected]/

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


Reply via email to