From: "Lai, Yi" <yi1.lai@intel.com>
To: Qinyun Tan <qinyuntan@linux.alibaba.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
yeeli <seven.yi.lee@gmail.com>,
Xunlei Pang <xlpang@linux.alibaba.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
yi1.lai@inte.com
Subject: Re: [PATCH] iommufd/selftest: Return dmabuf fd from IOMMU_TEST_OP_DMABUF_GET again
Date: Thu, 3 Sep 2026 16:08:44 +0800 [thread overview]
Message-ID: <apkrDCjfzBobiwm/@ly-workstation> (raw)
In-Reply-To: <20260902085414.549830-1-qinyuntan@linux.alibaba.com>
On Wed, Sep 02, 2026 at 04:54:14PM +0800, Qinyun Tan wrote:
> The selftest helper reads the new dmabuf fd from the ioctl return
> value:
>
> *out_fd = ioctl(fd, IOMMU_TEST_CMD, &cmd);
>
> Commit dba4254e216d ("iommufd/selftest: Fix dmabuf leak in
> iommufd_test_dmabuf_get()") fixed the dmabuf leak on dma_buf_fd()
> failure, but the applied version also changed the success path to
> return 0, so userspace no longer receives the fd. Note the patch as
> posted on the list returned rc here; the change to return 0 appeared
> when it was applied:
>
> https://lore.kernel.org/all/20260707030635.221577-1-seven.yi.lee@gmail.com/
>
> Every test using test_cmd_get_dmabuf() then operates on fd 0 instead
> of the dmabuf, and the dmabuf_simple and dmabuf_revoke selftests fail
> across all fixtures:
>
> # iommufd.c:1595:dmabuf_simple:Expected -1 (-1) ==
> _test_ioctl_ioas_map_file(...) (0)
>
> Keep the dma_buf_put() on failure but return the fd on success.
>
> Fixes: dba4254e216d ("iommufd/selftest: Fix dmabuf leak in iommufd_test_dmabuf_get()")
> Signed-off-by: Qinyun Tan <qinyuntan@linux.alibaba.com>
> ---
> drivers/iommu/iommufd/selftest.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
> index ee706f18f7e91..f6da927461b57 100644
> --- a/drivers/iommu/iommufd/selftest.c
> +++ b/drivers/iommu/iommufd/selftest.c
> @@ -2056,11 +2056,9 @@ static int iommufd_test_dmabuf_get(struct iommufd_ucmd *ucmd,
> }
>
> rc = dma_buf_fd(dmabuf, open_flags);
> - if (rc < 0) {
> + if (rc < 0)
> dma_buf_put(dmabuf);
> - return rc;
> - }
> - return 0;
> + return rc;
>
> err_free:
> kfree(priv->memory);
> --
> 2.43.7
>
Applied on upstream v7.3-rc1 kernel, issue was resolved.
Tested-by: Yi Lai <yi1.lai@intel.com>
next prev parent reply other threads:[~2026-09-03 8:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 8:54 Qinyun Tan
2026-09-02 13:47 ` Yee Li
2026-09-03 8:08 ` Lai, Yi [this message]
2026-09-09 16:23 ` 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=apkrDCjfzBobiwm/@ly-workstation \
--to=yi1.lai@intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=qinyuntan@linux.alibaba.com \
--cc=robin.murphy@arm.com \
--cc=seven.yi.lee@gmail.com \
--cc=will@kernel.org \
--cc=xlpang@linux.alibaba.com \
--cc=yi1.lai@inte.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
all inboxes | Powered by JetHome®