lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALzav=fseMCyQEvBsJa+J+_V=1S3MX_7sArEksGYUQAey==70g@mail.gmail.com>
Date: Tue, 25 Nov 2025 09:37:15 -0800
From: David Matlack <dmatlack@...gle.com>
To: Raghavendra Rao Ananta <rananta@...gle.com>
Cc: Alex Williamson <alex@...zbot.org>, Alex Mastro <amastro@...com>, Jason Gunthorpe <jgg@...dia.com>, 
	Josh Hilke <jrhilke@...gle.com>, kvm@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-kselftest@...r.kernel.org, Vipin Sharma <vipinsh@...gle.com>
Subject: Re: [PATCH v3 06/18] vfio: selftests: Support multiple devices in the
 same container/iommufd

On Mon, Nov 24, 2025 at 3:17 AM Raghavendra Rao Ananta
<rananta@...gle.com> wrote:
> On Fri, Nov 21, 2025 at 11:44 PM David Matlack <dmatlack@...gle.com> wrote:
> > +struct vfio_pci_device *vfio_pci_device_init(const char *bdf, struct iommu *iommu)
> >  {
> >         struct vfio_pci_device *device;
> >
> >         device = calloc(1, sizeof(*device));
> >         VFIO_ASSERT_NOT_NULL(device);
> >
> > -       device->iommu = calloc(1, sizeof(*device->iommu));
> > -       VFIO_ASSERT_NOT_NULL(device->iommu);
> > -
> > -       INIT_LIST_HEAD(&device->iommu->dma_regions);
> > -
> > -       device->iommu->mode = lookup_iommu_mode(iommu_mode);
> > +       device->iommu = iommu;
> nit: Since we now depend on the caller to follow the right order,
> should we have a VFIO_ASSERT_NOT_NULL(iommu), or something along the
> lines of 'Is iommu initialized?" before this function starts using it,
> and fail with an appropriate error message?

I think the compiler and type system largely enforce the order now.
The compiler will complain if a user passes in an uninitialized struct
iommu *. And the only way to initialize it is with iommu_init(). I
guess someone could pass in NULL, so having an explicit assert for
non-null would be easier to debug than a SIGSEGV. I'll add that in v4.

>
> >
> >         if (device->iommu->mode->container_path)
> minor nit: if there's a v4, simply use iommu->mode->container_path.

Yes, thanks, will do!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ