From: Pranjal Shrivastava <praan@google.com>
To: iommu@lists.linux.dev
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Jason Gunthorpe <jgg@nvidia.com>,
Kevin Tian <kevin.tian@intel.com>,
Nicolin Chen <nicolinc@nvidia.com>,
Samiullah Khawaja <skhawaja@google.com>,
Peter Shier <pshier@google.com>,
Pranjal Shrivastava <praan@google.com>
Subject: [PATCH] iommu: Honor iommufd uapi for zero entry_num args
Date: Wed, 2 Sep 2026 12:43:33 +0000 [thread overview]
Message-ID: <20260902124333.2461949-1-praan@google.com> (raw)
The IOMMU_HWPT_INVALIDATE ioctl uAPI explicitly allows an empty
invalidation request array by setting entry_num == 0. The uAPI
documentation in include/uapi/linux/iommufd.h mentions:
" An empty invalidation request array by setting @entry_num==0
is allowed, and @entry_len and @data_uptr would be ignored in
this case."
While the core iommufd_hwpt_invalidate() handler honors this by
skipping its bounds checks, the generic array copy helper
iommu_copy_struct_from_full_user_array() incorrectly rejects it
by returning -EINVAL, breaking the uAPI.
Fix this by returning 0 instead of -EINVAL when entry_num is 0.
Fixes: 4f2e59ccb698 ("iommu: Add iommu_copy_struct_from_full_user_array helper")
Signed-off-by: Pranjal Shrivastava <praan@google.com>
---
include/linux/iommu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index ac43b8b93f14..cf16f9649645 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -569,7 +569,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;
if (likely(user_array->entry_len == kdst_entry_size)) {
if (copy_from_user(kdst, user_array->uptr,
user_array->entry_num *
--
2.55.0.966.g6673acef38-goog
next reply other threads:[~2026-09-02 12:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 12:43 Pranjal Shrivastava [this message]
2026-09-02 15:13 ` [PATCH] iommu: Honor iommufd uapi for zero entry_num args Nicolin Chen
2026-09-02 16:04 ` Pranjal Shrivastava
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=20260902124333.2461949-1-praan@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=skhawaja@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox