Re: [PATCH] tpm: track the response read position internally, not via the file offset

From: Rustam Mustafin

Date: Fri Nov 20 2026 - 07:20:25 EST


On Fri, Nov 20, 2026 at 1:13 AM Jarkko Sakkinen <jarkko@xxxxxxxxxx> wrote:
> > 1. ->read_iter and ->write_iter that just return -EINVAL.
> >
> > Simple, but readv() and single-iovec writev() stop working.
>
> So. What would be the use case for this?

I don't know of a real user, tpm2-tss uses read() and write(). It is
about compatibility: readv() works today and can split a response,
e.g. the 10-byte header into one buffer and the body into another.
writev() is less useful, since a command must fit in one iovec.

> 2 is a bug fix, enabling is a feature. I guess this is the confusion.

Adding ->read_iter for 2 also lets vfs_iter_read() callers such as
Coda reach tpm_common_read(). Their requests look the same as readv(),
so the checks in 2 cannot tell them apart. That's why I sent the read
position fix as v2 first:
https://lore.kernel.org/all/20261120121614.978396-1-rmustafin@xxxxxxxxxxxxxx/

With it, tpm_common_read() ignores *off, so io_uring reads and writes
work correctly. I'm not sure about blocking io_uring on top of that:
it works today, and I can't rule out users, especially of /dev/tpmrm0,
which many processes can open at once. I have 2 implemented and
tested, with -EIO, and can send it if it's needed.

Br,
Rustam