From: Jarkko Sakkinen <jarkko@kernel.org>
To: Rustam Mustafin <rmustafin@cloudlinux.com>
Cc: Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
Jaewon Yang <yong010301@gmail.com>,
Tadeusz Struk <tadeusz.struk@intel.com>,
linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] tpm: track the response read position internally, not via the file offset
Date: Thu, 19 Nov 2026 20:13:06 +0200 [thread overview]
Message-ID: <av88MkHFBHTD8Rqe@kernel.org> (raw)
In-Reply-To: <CAG6=z5u+qK3JQ4OwqS8e9ncfcasYPWLQhU9Y4iBFi1pEf0QFuQ@mail.gmail.com>
On Fri, Nov 20, 2026 at 12:49:37AM +0700, Rustam Mustafin wrote:
> On Wed, Nov 18, 2026 at 9:33 PM Jarkko Sakkinen <jarkko@kernel.org> 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.
So. What would be the use case for this?
>
> 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.
So given how TPM works (reserved for only one process) I tend to prefer
this. But -EIO should be used. It's as IO failure as it gets.
>
> 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.
2 is a bug fix, enabling is a feature. I guess this is the confusion.
>
> 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
/Jarkko
next prev parent reply other threads:[~2026-11-19 18:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 9:02 [PATCH] tpm: Reject reads outside the response buffer Jaewon Yang
2026-07-11 17:08 ` Jarkko Sakkinen
2026-07-11 18:58 ` Linus Torvalds
2026-07-12 17:11 ` [PATCH v2] tpm: Make the TPM character devices non-seekable Jaewon Yang
2026-07-12 19:54 ` Linus Torvalds
2026-07-18 18:13 ` Jarkko Sakkinen
2026-07-18 18:20 ` Jarkko Sakkinen
2026-11-17 10:48 ` [PATCH] tpm: track the response read position internally, not via the file offset Rustam Mustafin
2026-11-17 10:59 ` Jarkko Sakkinen
2026-11-17 12:35 ` Jarkko Sakkinen
2026-11-17 12:38 ` Jarkko Sakkinen
2026-11-18 9:55 ` Rustam Mustafin
[not found] ` <CAG6=z5sxUo1x6mpotkNZXk=nQYvD2AyMLSDhzD3B3kqxJ1=iaw@mail.gmail.com>
2026-11-18 14:33 ` Jarkko Sakkinen
2026-11-19 17:49 ` Rustam Mustafin
2026-11-19 18:13 ` Jarkko Sakkinen [this message]
2026-07-18 18:17 ` [PATCH] tpm: Reject reads outside the response buffer Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=av88MkHFBHTD8Rqe@kernel.org \
--to=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=rmustafin@cloudlinux.com \
--cc=stable@vger.kernel.org \
--cc=tadeusz.struk@intel.com \
--cc=yong010301@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox