From: Pranjal Shrivastava <praan@google.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: jgg@nvidia.com, kevin.tian@intel.com, joro@8bytes.org,
baolu.lu@linux.intel.com, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v1 6/7] iommufd: Avoid partial fault group delivery in iommufd_fault_fops_read()
Date: Wed, 3 Jun 2026 14:26:30 +0000 [thread overview]
Message-ID: <aiA5lmader-zPqEd@google.com> (raw)
In-Reply-To: <360cab4d4aeccb0bae275a970e2b3c340a71e0e0.1780343944.git.nicolinc@nvidia.com>
On Mon, Jun 01, 2026 at 01:42:37PM -0700, Nicolin Chen wrote:
> The cookie returned by xa_alloc() in iommufd_fault_fops_read() is per fault
> group, but the inner copy_to_user() runs per fault inside the group. If a
> copy fails mid-group, xa_erase clears the cookie and the group is restored
> to the deliver list, yet done is not rolled back. The function returns the
> partial byte count, with the successfully copied faults sitting at offsets
> below done carrying the now-erased cookie. The next read() then re-fetches
> the group, allocates a fresh cookie, and re-delivers every fault including
> the ones already copied; userspace sees duplicates carrying the new cookie,
> and a stale cookie that can never be responded to.
>
> Use a local group_done variable that tracks the per-group progress inside
> the inner loop, and only commit done = group_done after the inner loop has
> finished successfully. On a copy_to_user failure the outer break skips the
> commit, so done remains at its prior start-of-group baseline; the partial
> bytes already written past done are undefined to userspace per the read(2)
> contract, and the next read re-delivers the whole group atomically.
>
> Fixes: 07838f7fd529 ("iommufd: Add iommufd fault object")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-4-7
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Thanks,
Praan
next prev parent reply other threads:[~2026-06-03 14:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 20:42 [PATCH v1 0/7] iommufd: Fix bugs in eventq fops_read paths Nicolin Chen
2026-06-01 20:42 ` [PATCH v1 1/7] iommufd: Rewind header length in done if iommufd_veventq_fops_read() fails Nicolin Chen
2026-06-03 14:01 ` Pranjal Shrivastava
2026-06-01 20:42 ` [PATCH v1 2/7] iommufd: Reject invalid read count in iommufd_veventq_fops_read() Nicolin Chen
2026-06-03 14:08 ` Pranjal Shrivastava
2026-06-01 20:42 ` [PATCH v1 3/7] iommufd: Propagate allocation failure in iommufd_veventq_deliver_fetch() Nicolin Chen
2026-06-03 14:13 ` Pranjal Shrivastava
2026-06-01 20:42 ` [PATCH v1 4/7] iommufd: Reject invalid read count in iommufd_fault_fops_read() Nicolin Chen
2026-06-03 14:15 ` Pranjal Shrivastava
2026-06-01 20:42 ` [PATCH v1 5/7] iommufd: Break the loop on failure " Nicolin Chen
2026-06-03 14:18 ` Pranjal Shrivastava
2026-06-01 20:42 ` [PATCH v1 6/7] iommufd: Avoid partial fault group delivery " Nicolin Chen
2026-06-03 14:26 ` Pranjal Shrivastava [this message]
2026-06-01 20:42 ` [PATCH v1 7/7] iommufd/selftest: Cover invalid read counts on vEVENTQ FD Nicolin Chen
2026-06-03 14:46 ` Pranjal Shrivastava
2026-06-02 6:27 ` [PATCH v1 0/7] iommufd: Fix bugs in eventq fops_read paths Nicolin Chen
2026-06-03 6:59 ` Tian, Kevin
2026-06-05 14:30 ` Jason Gunthorpe
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=aiA5lmader-zPqEd@google.com \
--to=praan@google.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=nicolinc@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.