From: Pranjal Shrivastava <praan@google.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>,
Kevin Tian <kevin.tian@intel.com>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Joerg Roedel <joro@8bytes.org>, Peter Shier <pshier@google.com>,
iommu@lists.linux.dev
Subject: Re: [PATCH v2] iommu: Honor iommufd uapi for zero entry_num args
Date: Mon, 16 Nov 2026 11:27:20 +0000 [thread overview]
Message-ID: <avromFJ6opeGEcT_@google.com> (raw)
In-Reply-To: <avdO5cBwc/2ysstZ@nvidia.com>
On Fri, Nov 13, 2026 at 09:54:45AM -0800, Nicolin Chen wrote:
> On Thu, Nov 12, 2026 at 03:10:39PM +0000, Pranjal Shrivastava wrote:
> > @@ -556,7 +556,8 @@ static inline int __iommu_copy_struct_from_user_array(
> > * @data_type: The data type of the @kdst. Must match with @user_array->type
> > *
> > * Copy the entire user array. kdst must have room for kdst_entry_size *
> > - * user_array->entry_num bytes. Return 0 for success, otherwise -error.
> > + * user_array->entry_num bytes. An empty array copies nothing, though its
> > + * @data_type is still validated. Return 0 for success, otherwise -error.
> > */
> > static inline int
> > iommu_copy_struct_from_full_user_array(void *kdst, size_t kdst_entry_size,
> > @@ -569,7 +570,7 @@ iommu_copy_struct_from_full_user_array(void *kdst, size_t kdst_entry_size,
> > if (user_array->type != data_type)
> > return -EINVAL;
> > if (!user_array->entry_num)
> > - return -EINVAL;
> > + return 0;
>
> TBH, this doesn't seem very necessary..
>
> Though I don't have a problem so long as Jason is okay with it..
>
I know it looks unnecessary in-tree, but zero-length is the documented
way to check if a @data_type is supported. Intel and the selftest check
entry_num before their single-entry copy, but arm, the only caller of
the full-array helper, didn't and returned -EINVAL for that probe until
your patch [1]. I've seen an issue downstream where a driver called the
full-array helper on the array as-is, and the probe failed with -EINVAL.
> Yet, this alone would make things inconsistent:
> * The other caller in iommufd selftest isn't updated.
The selftest hasn't used the full-array helper since your patch [2]
switched it to iommu_copy_struct_from_user_array(), arm is the only
caller now (unless I'm missing something?)
> * __iommu_copy_struct_from_user_array still rejects !entry_num,
> and its callers (intel and selftest) aren't updated either.
That one copies the entry at @index, and an empty array has no entry,
so its callers have to check entry_num before indexing regardless. The
full-array helper is more like a zero-length copy_from_user().
> Also, please don't omit "linux-kernel@vger.kernel.org" when sending
> a patch, as linux-iommu doesn't trigger Sashiko scan.
Ack, will keep LKML in Cc.
Thanks,
Praan
[1] https://lore.kernel.org/all/5223275dbc8ef00af233f3fee01efa09e45f26b5.1788127877.git.nicolinc@nvidia.com/
[2] https://lore.kernel.org/all/535f3b97e16c437f1df0c988a96229f623142ee9.1788127877.git.nicolinc@nvidia.com/
next prev parent reply other threads:[~2026-11-16 11:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 15:10 [PATCH v2] iommu: Honor iommufd uapi for zero entry_num args Pranjal Shrivastava
2026-11-13 17:54 ` Nicolin Chen
2026-11-16 11:27 ` Pranjal Shrivastava [this message]
2026-11-16 13:08 ` Jason Gunthorpe
2026-11-16 20:21 ` Pranjal Shrivastava
2026-11-16 20:23 ` Jason Gunthorpe
2026-11-16 20:31 ` Pranjal Shrivastava
2026-11-16 23:41 ` 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=avromFJ6opeGEcT_@google.com \
--to=praan@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=nicolinc@nvidia.com \
--cc=pshier@google.com \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/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.