From: Nicolin Chen <nicolinc@nvidia.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
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 11:46:50 -0800 [thread overview]
Message-ID: <Z46oKvURNEjl0XRZ@nvidia.com> (raw)
In-Reply-To: <20250120143719.GN674319@ziepe.ca>
On Mon, Jan 20, 2025 at 10:37:19AM -0400, Jason Gunthorpe wrote:
> 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
Sending a v3.
I think having the zeroing in iommufd_fault_fops_read can drop
the "__reserved = 0" iommufd_compose_fault_message.
Thanks
Nicolin
next prev parent reply other threads:[~2025-01-20 19:47 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
2025-01-20 19:46 ` Nicolin Chen [this message]
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=Z46oKvURNEjl0XRZ@nvidia.com \
--to=nicolinc@nvidia.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.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