tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
Subsystems (3)
v3 cover tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
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
Signature · 1 line
2.52.0
PATCH v3 1/2 tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
io_uring passes its own file offset to the TPM character devices, although they are opened with nonseekable_open(): IORING_OP_READ copies sqe->off into ki_pos without checking FMODE_PREAD. The devices also keep a single command and response per open file, which does not fit asynchronous requests.
Add tpm_common_read_iter() and tpm_common_write_iter(), which fail io_uring and AIO requests with -EIO. A multishot read uses a synchronous kiocb, so also reject IOCB_NOWAIT and io-wq workers. The callbacks call tpm_common_read() and tpm_common_write() once per iovec, so readv() can still split a response into the header and the body.
--- 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 + 4 files changed, 76 insertions(+)
drivers/char/tpm/tpm-dev-common.c +70 -0
@@ -13,8 +13,10 @@* Device file system interface to the TPM */ #include <linux/poll.h> +#include <linux/sched.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/uio.h> #include <linux/workqueue.h> #include "tpm.h" #include "tpm-dev.h"
@@ -253,6 +255,74 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,return ret; } +/* +* Reject io_uring and AIO. IORING_OP_READ_MULTISHOT requests use a +* synchronous kiocb, so also check for NOWAIT attempts and io-wq workers. +*/ +static bool tpm_iter_is_async (struct kiocb *iocb) +{ +return !is_sync_kiocb (iocb) || + (iocb->ki_flags &IOCB_NOWAIT ) || + (current->flags &PF_IO_WORKER ); +} + +/* Preserve the VFS fallback's per-iovec read/write semantics. */ +ssize_t tpm_common_read_iter (struct kiocb *iocb,struct iov_iter *to) +{ +struct file *file = iocb->ki_filp; +ssize_t ret =0 ; + +if (tpm_iter_is_async (iocb) || !user_backed_iter (to)) +return -EIO ; + +while (iov_iter_count (to)) { +size_t len =iter_iov_len (to); +ssize_t nr; + + nr =tpm_common_read (file,iter_iov_addr (to), + len, &iocb->ki_pos); +if (nr <0 ) { +if (!ret) + ret = nr; +break ; + } + ret += nr; +iov_iter_advance (to, nr); +if (nr != len) +break ; + } + +return ret; +} + +ssize_t tpm_common_write_iter (struct kiocb *iocb,struct iov_iter *from) +{ +struct file *file = iocb->ki_filp; +ssize_t ret =0 ; + +if (tpm_iter_is_async (iocb) || !user_backed_iter (from)) +return -EIO ; + +while (iov_iter_count (from)) { +size_t len =iter_iov_len (from); +ssize_t nr; + + nr =tpm_common_write (file,iter_iov_addr (from), + len, &iocb->ki_pos); +if (nr <0 ) { +if (!ret) + ret = nr; +break ; + } + ret += nr; +iov_iter_advance (from, nr); +if (nr != len) +break ; + } + +return ret; +} +__poll_t tpm_common_poll (struct file *file,poll_table *wait) {struct file_priv *priv = file->private_data;
drivers/char/tpm/tpm-dev.c +2 -0
@@ -62,6 +62,8 @@ const struct file_operations tpm_fops = { .open = tpm_open, .read = tpm_common_read, .write = tpm_common_write, + .read_iter = tpm_common_read_iter, + .write_iter = tpm_common_write_iter, .poll = tpm_common_poll, .release = tpm_release, };
drivers/char/tpm/tpm-dev.h +2 -0
@@ -28,6 +28,8 @@ ssize_t tpm_common_read(struct file *file, char __user *buf, size_t size, loff_t *off);ssize_t tpm_common_write (struct file *file,const char __user *buf,size_t size,loff_t *off); +ssize_t tpm_common_read_iter (struct kiocb *iocb,struct iov_iter *to); +ssize_t tpm_common_write_iter (struct kiocb *iocb,struct iov_iter *from);__poll_t tpm_common_poll (struct file *file,poll_table *wait);void tpm_common_release (struct file *file,struct file_priv *priv);
drivers/char/tpm/tpmrm-dev.c +2 -0
@@ -49,6 +49,8 @@ const struct file_operations tpmrm_fops = { .open = tpmrm_open, .read = tpm_common_read, .write = tpm_common_write, + .read_iter = tpm_common_read_iter, + .write_iter = tpm_common_write_iter, .poll = tpm_common_poll, .release = tpmrm_release, };
Signature · 1 line
2.52.0
PATCH v3 2/2 selftests: tpm2: test that io_uring reads are rejected
In reply to Rustam MustafinTest that IORING_OP_READ on /dev/tpm0 and /dev/tpmrm0 fails with -EIO and that the following read() returns the whole response. The test needs liburing-ffi (liburing 2.4+) and is skipped without it.
--- tools/testing/selftests/tpm2/Makefile | 2 +- tools/testing/selftests/tpm2/test_uring.sh | 15 +++++ tools/testing/selftests/tpm2/tpm2_tests.py | 72 ++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/tpm2/test_uring.sh
tools/testing/selftests/tpm2/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) include ../lib.mk -TEST_PROGS := test_smoke.sh test_space.sh test_async.sh +TEST_PROGS := test_smoke.sh test_space.sh test_async.sh test_uring.sh TEST_PROGS_EXTENDED := tpm2.py tpm2_tests.py
tools/testing/selftests/tpm2/test_uring.sh new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +[ -e /dev/tpm0 ] || exit $ksft_skip +[ -e /dev/tpmrm0 ] || exit $ksft_skip +read tpm_version < /sys/class/tpm/tpm0/tpm_version_major +[ "$tpm_version" = 2 ] || exit $ksft_skip + +python3 -c 'import sys, tpm2_tests +sys.exit(not tpm2_tests.uring_available())' || exit $ksft_skip + +python3 -m unittest -v tpm2_tests.UringTest 2>&1
tools/testing/selftests/tpm2/tpm2_tests.py +72 -0
81 lines not on this page · raw message
Signature · 1 line
2.52.0
Jarkko Sakkinen
maintainerQuoted 1 line · Rustam Mustafin
Assisted-by Claude:claude-opus-5-5
Drop this and send one more.
Br, Jarkko
PATCH v3 1/2 tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
io_uring passes its own file offset to the TPM character devices, although they are opened with nonseekable_open(): IORING_OP_READ copies sqe->off into ki_pos without checking FMODE_PREAD. The devices also keep a single command and response per open file, which does not fit asynchronous requests.
Add tpm_common_read_iter() and tpm_common_write_iter(), which fail io_uring and AIO requests with -EIO. A multishot read uses a synchronous kiocb, so also reject IOCB_NOWAIT and io-wq workers. The callbacks call tpm_common_read() and tpm_common_write() once per iovec, so readv() can still split a response into the header and the body.
---
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 + 4 files changed, 76 insertions(+)
drivers/char/tpm/tpm-dev-common.c +70 -0
@@ -13,8 +13,10 @@* Device file system interface to the TPM */ #include <linux/poll.h> +#include <linux/sched.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/uio.h> #include <linux/workqueue.h> #include "tpm.h" #include "tpm-dev.h"
@@ -253,6 +255,74 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,return ret; } +/* +* Reject io_uring and AIO. IORING_OP_READ_MULTISHOT requests use a +* synchronous kiocb, so also check for NOWAIT attempts and io-wq workers. +*/ +static bool tpm_iter_is_async (struct kiocb *iocb) +{ +return !is_sync_kiocb (iocb) || + (iocb->ki_flags &IOCB_NOWAIT ) || + (current->flags &PF_IO_WORKER ); +} + +/* Preserve the VFS fallback's per-iovec read/write semantics. */ +ssize_t tpm_common_read_iter (struct kiocb *iocb,struct iov_iter *to) +{ +struct file *file = iocb->ki_filp; +ssize_t ret =0 ; + +if (tpm_iter_is_async (iocb) || !user_backed_iter (to)) +return -EIO ; + +while (iov_iter_count (to)) { +size_t len =iter_iov_len (to); +ssize_t nr; + + nr =tpm_common_read (file,iter_iov_addr (to), + len, &iocb->ki_pos); +if (nr <0 ) { +if (!ret) + ret = nr; +break ; + } + ret += nr; +iov_iter_advance (to, nr); +if (nr != len) +break ; + } + +return ret; +} + +ssize_t tpm_common_write_iter (struct kiocb *iocb,struct iov_iter *from) +{ +struct file *file = iocb->ki_filp; +ssize_t ret =0 ; + +if (tpm_iter_is_async (iocb) || !user_backed_iter (from)) +return -EIO ; + +while (iov_iter_count (from)) { +size_t len =iter_iov_len (from); +ssize_t nr; + + nr =tpm_common_write (file,iter_iov_addr (from), + len, &iocb->ki_pos); +if (nr <0 ) { +if (!ret) + ret = nr; +break ; + } + ret += nr; +iov_iter_advance (from, nr); +if (nr != len) +break ; + } + +return ret; +} +__poll_t tpm_common_poll (struct file *file,poll_table *wait) {struct file_priv *priv = file->private_data;
drivers/char/tpm/tpm-dev.c +2 -0
@@ -62,6 +62,8 @@ const struct file_operations tpm_fops = { .open = tpm_open, .read = tpm_common_read, .write = tpm_common_write, + .read_iter = tpm_common_read_iter, + .write_iter = tpm_common_write_iter, .poll = tpm_common_poll, .release = tpm_release, };
drivers/char/tpm/tpm-dev.h +2 -0
@@ -28,6 +28,8 @@ ssize_t tpm_common_read(struct file *file, char __user *buf, size_t size, loff_t *off);ssize_t tpm_common_write (struct file *file,const char __user *buf,size_t size,loff_t *off); +ssize_t tpm_common_read_iter (struct kiocb *iocb,struct iov_iter *to); +ssize_t tpm_common_write_iter (struct kiocb *iocb,struct iov_iter *from);__poll_t tpm_common_poll (struct file *file,poll_table *wait);void tpm_common_release (struct file *file,struct file_priv *priv);
drivers/char/tpm/tpmrm-dev.c +2 -0
@@ -49,6 +49,8 @@ const struct file_operations tpmrm_fops = { .open = tpmrm_open, .read = tpm_common_read, .write = tpm_common_write, + .read_iter = tpm_common_read_iter, + .write_iter = tpm_common_write_iter, .poll = tpm_common_poll, .release = tpmrm_release, };
Signature · 1 line
2.52.0
PATCH v3 2/2 selftests: tpm2: test that io_uring reads are rejected
Test that IORING_OP_READ on /dev/tpm0 and /dev/tpmrm0 fails with -EIO and that the following read() returns the whole response. The test needs liburing-ffi (liburing 2.4+) and is skipped without it.
---
tools/testing/selftests/tpm2/Makefile | 2 +- tools/testing/selftests/tpm2/test_uring.sh | 15 +++++ tools/testing/selftests/tpm2/tpm2_tests.py | 72 ++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/tpm2/test_uring.sh
tools/testing/selftests/tpm2/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) include ../lib.mk -TEST_PROGS := test_smoke.sh test_space.sh test_async.sh +TEST_PROGS := test_smoke.sh test_space.sh test_async.sh test_uring.sh TEST_PROGS_EXTENDED := tpm2.py tpm2_tests.py
tools/testing/selftests/tpm2/test_uring.sh new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +[ -e /dev/tpm0 ] || exit $ksft_skip +[ -e /dev/tpmrm0 ] || exit $ksft_skip +read tpm_version < /sys/class/tpm/tpm0/tpm_version_major +[ "$tpm_version" = 2 ] || exit $ksft_skip + +python3 -c 'import sys, tpm2_tests +sys.exit(not tpm2_tests.uring_available())' || exit $ksft_skip + +python3 -m unittest -v tpm2_tests.UringTest 2>&1
tools/testing/selftests/tpm2/tpm2_tests.py +72 -0
81 lines not on this page · raw message
Signature · 1 line
2.52.0
Re: [PATCH v3 2/2] selftests: tpm2: test that io_uring reads are rejected
Quoted 135 lines · Rustam Mustafin
Test that
IORING_OP_READon/dev/tpm0and/dev/tpmrm0fails with-EIOand that the followingread()returns the whole response. The test needs liburing-ffi (liburing 2.4+) and is skipped without it.Signed-off-by Rustam Mustafin <[email protected]>---
tools/testing/selftests/tpm2/Makefile | 2 +- tools/testing/selftests/tpm2/test_uring.sh | 15 +++++ tools/testing/selftests/tpm2/tpm2_tests.py | 72 ++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/tpm2/test_uring.shtools/testing/selftests/tpm2/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) include ../lib.mk -TEST_PROGS := test_smoke.sh test_space.sh test_async.sh +TEST_PROGS := test_smoke.sh test_space.sh test_async.sh test_uring.sh TEST_PROGS_EXTENDED := tpm2.py tpm2_tests.pytools/testing/selftests/tpm2/test_uring.sh new file +15
-0@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +[ -e /dev/tpm0 ] || exit $ksft_skip +[ -e /dev/tpmrm0 ] || exit $ksft_skip +read tpm_version < /sys/class/tpm/tpm0/tpm_version_major +[ "$tpm_version" = 2 ] || exit $ksft_skip + +python3 -c 'import sys, tpm2_tests +sys.exit(not tpm2_tests.uring_available())' || exit $ksft_skip + +python3 -m unittest -v tpm2_tests.UringTest 2>&1tools/testing/selftests/tpm2/tpm2_tests.py +72
-0@@ -9,6 +9,7 @@ from tpm2 import ProtocolError import unittest import logging import struct +import errno class SmokeTest(unittest.TestCase): def setUp(self):@@ -331,3 +332,74 @@ class AsyncTest(unittest.TestCase): self.assertEqual(rc, 22) async_client.close() + +def uring_available(): + import ctypes.util + + name = ctypes.util.find_library('uring-ffi') + if not name: + return False + lib = ctypes.CDLL(name) + ring = ctypes.create_string_buffer(1024) + if lib.io_uring_queue_init(1, ring, 0) < 0: + return False + lib.io_uring_queue_exit(ring) + return True + +def uring_read(fd, size): + import ctypes.util + + lib = ctypes.CDLL(ctypes.util.find_library('uring-ffi')) + lib.io_uring_get_sqe.restype = ctypes.c_void_p + lib.io_uring_prep_read.argtypes = [ctypes.c_void_p, ctypes.c_int, + ctypes.c_void_p, ctypes.c_uint, + ctypes.c_uint64] + ring = ctypes.create_string_buffer(1024) + ret = lib.io_uring_queue_init(1, ring, 0) + if ret < 0: + raise OSError(-ret, 'io_uring_queue_init') + try: + buf = ctypes.create_string_buffer(size) + lib.io_uring_prep_read(lib.io_uring_get_sqe(ring), fd, buf, size, 0) + ret = lib.io_uring_submit(ring) + if ret < 0: + raise OSError(-ret, 'io_uring_submit') + cqe = ctypes.c_void_p() + ret = lib.io_uring_wait_cqe(ring, ctypes.byref(cqe)) + if ret < 0: + raise OSError(-ret, 'io_uring_wait_cqe') + # cqe->res follows the 64-bit user_data + res = ctypes.c_int.from_address(cqe.value + 8).value + finally: + lib.io_uring_queue_exit(ring) + + return res + +class UringTest(unittest.TestCase): + def read_response(self, flags): + client = tpm2.Client(flags) + fmt = '>HII III' + cmd = struct.pack(fmt, + tpm2.TPM2_ST_NO_SESSIONS, + struct.calcsize(fmt), + tpm2.TPM2_CC_GET_CAPABILITY, + tpm2.TPM2_CAP_TPM_PROPERTIES, + tpm2.TPM2_PT_FIXED, 1) + try: + client.tpm.write(cmd) + res = uring_read(client.tpm.fileno(), 4096) + # The rejected read must leave the whole response in place + rsp = client.tpm.read(4096) + finally: + client.close() + + self.assertEqual(res, -errno.EIO) + sz, rc = struct.unpack('>II', rsp[2:10]) + self.assertEqual(sz, len(rsp)) + self.assertEqual(rc, 0) + + def test_read_tpm(self): + self.read_response(0) + + def test_read_tpmrm(self): + self.read_response(tpm2.Client.FLAG_SPACE)Signature · 1 line
2.52.0
Thanks this much better.
Br, Jarkko
Jarkko Sakkinen
maintainerQuoted 6 lines · Rustam Mustafin
io_uringpasses its own file offset to the TPM character devices, although they are opened withnonseekable_open():IORING_OP_READcopiessqe->offintoki_poswithout checkingFMODE_PREAD. The devices also keep a single command and response per open file, which does not fit asynchronous requests.
Quoted 7 lines
Add
tpm_common_read_iter()andtpm_common_write_iter(), which failio_uringand AIO requests with-EIO. A multishot read uses a synchronous kiocb, so also rejectIOCB_NOWAITand io-wq workers. The callbacks calltpm_common_read()andtpm_common_write()once per iovec, soreadv()can still split a response into the header and the body.Signed-off-by Rustam Mustafin <[email protected]>
Checkpatch with strict afaik already complains about assisted-by and it is not a discussion topic for me. I make people do enough effort to the patches so that they can call them of their own :-)
Br, Jarkko
Jarkko Sakkinen
maintainerQuoted 13 lines · Jarkko Sakkinen
Quoted 12 lines · Rustam Mustafin
io_uringpasses its own file offset to the TPM character devices, although they are opened withnonseekable_open():IORING_OP_READcopiessqe->offintoki_poswithout checkingFMODE_PREAD. The devices also keep a single command and response per open file, which does not fit asynchronous requests.Add
tpm_common_read_iter()andtpm_common_write_iter(), which failio_uringand AIO requests with-EIO. A multishot read uses a synchronous kiocb, so also rejectIOCB_NOWAITand io-wq workers. The callbacks calltpm_common_read()andtpm_common_write()once per iovec, soreadv()can still split a response into the header and the body.
Quoted 7 lines
Quoted 1 line
Signed-off-by Rustam Mustafin <[email protected]>Checkpatch with strict afaik already complains about assisted-by and it is not a discussion topic for me. I make people do enough effort to the patches so that they can call them of their own :-)
Br, Jarkko
b4 shazam for the message-id:
mutt -e "source ~/.mutt/muttrc.kernel"
Grabbing thread from lore.kernel.org/all/[email protected]/t.mbox.gz Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 8 messages in the thread
WARNING: duplicate messages found at index 1
Subject 1: tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
Subject 2: tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 2
Subject 1: selftests: tpm2: test that io_uring reads are rejected
Subject 2: tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
2 is not a reply... assume additional patch
Analyzing 0 code-review messages
Checking attestation on all messages, may take a moment...
---
✓ [PATCH v3 1/2] tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
✓ Signed: DKIM/cloudlinux.com
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Jarkko Sakkinen <[email protected]>
✓ [PATCH v3 2/2] selftests: tpm2: test that io_uring reads are rejected
✓ Signed: DKIM/cloudlinux.com
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Jarkko Sakkinen <[email protected]>
✓ [PATCH v3 1/2] tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
✓ Signed: DKIM/cloudlinux.com
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Jarkko Sakkinen <[email protected]>
ERROR: missing [4/2]!
---
Total patches: 3
---
WARNING: Thread incomplete!
Applying: tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
Applying: selftests: tpm2: test that io_uring reads are rejected
Applying: tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
Patch failed at 0003 tpm: Do not allow io_uring for /dev/tpm0 and /dev/tpmrm0
error: patch failed: drivers/char/tpm/tpm-dev-common.c:13
error: drivers/char/tpm/tpm-dev-common.c: patch does not apply
error: patch failed: drivers/char/tpm/tpm-dev.c:62
error: drivers/char/tpm/tpm-dev.c: patch does not apply
error: patch failed: drivers/char/tpm/tpm-dev.h:28
error: drivers/char/tpm/tpm-dev.h: patch does not apply
error: patch failed: drivers/char/tpm/tpmrm-dev.c:49
error: drivers/char/tpm/tpmrm-dev.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Press any key to continue...
Br, Jarkko
Jarkko Sakkinen
maintainerQuoted 67 lines · Jarkko Sakkinen
Quoted 13 lines · Jarkko Sakkinen
Quoted 12 lines · Rustam Mustafin
io_uringpasses its own file offset to the TPM character devices, although they are opened withnonseekable_open():IORING_OP_READcopiessqe->offintoki_poswithout checkingFMODE_PREAD. The devices also keep a single command and response per open file, which does not fit asynchronous requests.Add
tpm_common_read_iter()andtpm_common_write_iter(), which failio_uringand AIO requests with-EIO. A multishot read uses a synchronous kiocb, so also rejectIOCB_NOWAITand io-wq workers. The callbacks calltpm_common_read()andtpm_common_write()once per iovec, soreadv()can still split a response into the header and the body.Quoted 7 lines
Quoted 1 line
Signed-off-by Rustam Mustafin <[email protected]>Checkpatch with strict afaik already complains about assisted-by and it is not a discussion topic for me. I make people do enough effort to the patches so that they can call them of their own :-)
Br, Jarkko
b4 shazam for the message-id:
mutt -e "source ~/.mutt/muttrc.kernel"
Grabbing thread from lore.kernel.org/all/[email protected]/t.mbox.gz Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 8 messages in the thread
WARNING: duplicate messages found at index 1
Subject 1: tpm: Do not allowio_uringfor/dev/tpm0and/dev/tpmrm0
Subject 2: tpm: Do not allowio_uringfor/dev/tpm0and/dev/tpmrm0
2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 2
Subject 1: selftests: tpm2: test thatio_uringreads are rejected
Subject 2: tpm: Do not allowio_uringfor/dev/tpm0and/dev/tpmrm0
2 is not a reply... assume additional patch
Analyzing 0 code-review messages
Checking attestation on all messages, may take a moment...
---
✓ [PATCH v3 1/2] tpm: Do not allowio_uringfor/dev/tpm0and/dev/tpmrm0
✓ Signed: DKIM/cloudlinux.com
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Jarkko Sakkinen <[email protected]>
✓ [PATCH v3 2/2] selftests: tpm2: test thatio_uringreads are rejected
✓ Signed: DKIM/cloudlinux.com
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Jarkko Sakkinen <[email protected]>
✓ [PATCH v3 1/2] tpm: Do not allowio_uringfor/dev/tpm0and/dev/tpmrm0
✓ Signed: DKIM/cloudlinux.com
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Jarkko Sakkinen <[email protected]>
ERROR: missing [4/2]!
---
Total patches: 3
---
WARNING: Thread incomplete!
Applying: tpm: Do not allowio_uringfor/dev/tpm0and/dev/tpmrm0
Applying: selftests: tpm2: test thatio_uringreads are rejected
Applying: tpm: Do not allowio_uringfor/dev/tpm0and/dev/tpmrm0
Patch failed at 0003 tpm: Do not allowio_uringfor/dev/tpm0and/dev/tpmrm0
error: patch failed:drivers/char/tpm/tpm-dev-common.c:13
error:drivers/char/tpm/tpm-dev-common.c: patch does not apply
error: patch failed:drivers/char/tpm/tpm-dev.c:62
error:drivers/char/tpm/tpm-dev.c: patch does not apply
error: patch failed:drivers/char/tpm/tpm-dev.h:28
error:drivers/char/tpm/tpm-dev.h: patch does not apply
Quoted 8 lines
error: patch failed:
drivers/char/tpm/tpmrm-dev.c:49
error:drivers/char/tpm/tpmrm-dev.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false" Press any key to continue...
I got them applied with git am. It's better to use separate threads per patch set version.
They are in my master branch now.
Br, Jarkko