public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: kevin.tian@intel.com, baolu.lu@linux.intel.com,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH rc v2] iommufd: Explicitize struct iommu_hwpt_pgfault padding
Date: Mon, 20 Jan 2025 10:37:19 -0400	[thread overview]
Message-ID: <20250120143719.GN674319@ziepe.ca> (raw)
In-Reply-To: <20250120062411.1589-1-nicolinc@nvidia.com>

On Sun, Jan 19, 2025 at 10:24:11PM -0800, Nicolin Chen wrote:
> --- a/drivers/iommu/iommufd/fault.c
> +++ b/drivers/iommu/iommufd/fault.c
> @@ -253,6 +253,7 @@ static void iommufd_compose_fault_message(struct iommu_fault *fault,
>  	hwpt_fault->pasid = fault->prm.pasid;
>  	hwpt_fault->grpid = fault->prm.grpid;
>  	hwpt_fault->perm = fault->prm.perm;
> +	hwpt_fault->__reserved = 0;
>  	hwpt_fault->addr = fault->prm.addr;
>  	hwpt_fault->length = 0;
>  	hwpt_fault->cookie = cookie;

Yikes, so it was leaking kernel stack memory through the padding too.

We should zero init the stack struct to be safe:

@@ -247,7 +247,7 @@ static ssize_t iommufd_fault_fops_read(struct file *filep, char __user *buf,
 {
        size_t fault_size = sizeof(struct iommu_hwpt_pgfault);
        struct iommufd_fault *fault = filep->private_data;
-       struct iommu_hwpt_pgfault data;
+       struct iommu_hwpt_pgfault data = {};
        struct iommufd_device *idev;
        struct iopf_group *group;
        struct iopf_fault *iopf;

I can fix it up if that is the only change

Jason

  reply	other threads:[~2025-01-20 14:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20  6:24 [PATCH rc v2] iommufd: Explicitize struct iommu_hwpt_pgfault padding Nicolin Chen
2025-01-20 14:37 ` Jason Gunthorpe [this message]
2025-01-20 19:46   ` Nicolin Chen
2025-01-20 16:43 ` 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=20250120143719.GN674319@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox