Re: [PATCH] tpm: track the response read position internally, not via the file offset
From: Rustam Mustafin
Date: Thu Nov 19 2026 - 12:49:55 EST
On Wed, Nov 18, 2026 at 9:33 PM Jarkko Sakkinen <jarkko@xxxxxxxxxx> wrote:
> I wrote that out of my memory. I did not expect to be exactly out.
>
> Block uring.
Hi Jarkko,
I looked at three ways to do it:
1. ->read_iter and ->write_iter that just return -EINVAL.
Simple, but readv() and single-iovec writev() stop working.
2. ->read_iter and ->write_iter that keep readv()/writev() working
and fail with:
if (!is_sync_kiocb(iocb) ||
(iocb->ki_flags & IOCB_NOWAIT) ||
(current->flags & PF_IO_WORKER))
return -EINVAL;
The first check catches normal io_uring reads/writes and AIO. The
other two are for IORING_OP_READ_MULTISHOT, which uses a sync kiocb.
3. A new per-request flag set by io_uring and checked by TPM.
Needs io_uring/VFS changes and is harder to backport.
With 2 and 3, vfs_iter_read() callers such as Coda (which forwards
reads to a file passed in by its userspace daemon) can reach
tpm_common_read() with their own offset. Today these calls fail,
because the TPM files have no ->read_iter.
I have 2 implemented and tested. It would also need a check of *off
in tpm_common_read(), because of the above.
Which one do you prefer?
Br,
Rustam