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]
Date:   Fri, 19 May 2023 12:48:29 -0700
From:   Nicolin Chen <nicolinc@...dia.com>
To:     "Tian, Kevin" <kevin.tian@...el.com>
CC:     "Liu, Yi L" <yi.l.liu@...el.com>,
        "joro@...tes.org" <joro@...tes.org>,
        "alex.williamson@...hat.com" <alex.williamson@...hat.com>,
        "jgg@...dia.com" <jgg@...dia.com>,
        "robin.murphy@....com" <robin.murphy@....com>,
        "baolu.lu@...ux.intel.com" <baolu.lu@...ux.intel.com>,
        "cohuck@...hat.com" <cohuck@...hat.com>,
        "eric.auger@...hat.com" <eric.auger@...hat.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "mjrosato@...ux.ibm.com" <mjrosato@...ux.ibm.com>,
        "chao.p.peng@...ux.intel.com" <chao.p.peng@...ux.intel.com>,
        "yi.y.sun@...ux.intel.com" <yi.y.sun@...ux.intel.com>,
        "peterx@...hat.com" <peterx@...hat.com>,
        "jasowang@...hat.com" <jasowang@...hat.com>,
        "shameerali.kolothum.thodi@...wei.com" 
        <shameerali.kolothum.thodi@...wei.com>,
        "lulu@...hat.com" <lulu@...hat.com>,
        "suravee.suthikulpanit@....com" <suravee.suthikulpanit@....com>,
        "iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
        "Duan, Zhenzhong" <zhenzhong.duan@...el.com>
Subject: Re: [PATCH v2 06/11] iommufd: IOMMU_HWPT_ALLOC allocation with user
 data

On Fri, May 19, 2023 at 09:41:00AM +0000, Tian, Kevin wrote:
> External email: Use caution opening links or attachments
> 
> 
> > From: Yi Liu <yi.l.liu@...el.com>
> > Sent: Thursday, May 11, 2023 10:39 PM
> > +     if (cmd->hwpt_type != IOMMU_HWPT_TYPE_DEFAULT) {
> > +             if (!ops->domain_alloc_user_data_len) {
> > +                     rc = -EOPNOTSUPP;
> > +                     goto out_put_idev;
> > +             }
> > +             klen = ops->domain_alloc_user_data_len(cmd->hwpt_type);
> > +             if (WARN_ON(klen < 0)) {
> > +                     rc = -EINVAL;
> > +                     goto out_put_pt;
> > +             }
> > +     }
> 
> What about passing the user pointer to the iommu driver which
> then does the copy so we don't need an extra @data_len()
> callback for every driver?

It's doable by letting the driver do copy_from_user(), yet I
recall that Jason suggested to keep it in the iommufd. Also,
we are reusing the ucmd_buffer for the user_data. And the klen
isn't really being used for its value here. So, it is likely
enough to have an ops->hwpt_type_is_supported.

> >
> > +     switch (pt_obj->type) {
> > +     case IOMMUFD_OBJ_IOAS:
> > +             ioas = container_of(pt_obj, struct iommufd_ioas, obj);
> > +             break;
> 
> this should fail if parent is specified.

I don't think that's necessaray: the parent is NULL by default
and only specified (if IOMMUFD_OBJ_HW_PAGETABLE) by the exact
pt_id/pt_obj here.

> > +     case IOMMUFD_OBJ_HW_PAGETABLE:
> > +             /* pt_id points HWPT only when hwpt_type
> > is !IOMMU_HWPT_TYPE_DEFAULT */
> > +             if (cmd->hwpt_type == IOMMU_HWPT_TYPE_DEFAULT) {
> > +                     rc = -EINVAL;
> > +                     goto out_put_pt;
> > +             }
> > +
> > +             parent = container_of(pt_obj, struct iommufd_hw_pagetable,
> > obj);
> > +             /*
> > +              * Cannot allocate user-managed hwpt linking to
> > auto_created
> > +              * hwpt. If the parent hwpt is already a user-managed hwpt,
> > +              * don't allocate another user-managed hwpt linking to it.
> > +              */
> > +             if (parent->auto_domain || parent->parent) {
> > +                     rc = -EINVAL;
> > +                     goto out_put_pt;
> > +             }
> > +             ioas = parent->ioas;
> 
> for nesting why is ioas required? In concept we can just pass NULL ioas
> to iommufd_hw_pagetable_alloc() for this hwpt. If within that function
> there is a need to toggle ioas for the parent it can always retrieve it
> from the parent hwpt.

Jason suggested this for simplicity. As I replied in another
email, a user hwpt still needs ioas's refcount and mutex, so
it would otherwise have a duplicated code in the beginning of
most of hwpt_ functions:
	if (hwpt->parent)
		ioas = hwpt->parent->ioas;
	else (hwpt->ioas)
		ioas = hwpt->ioas;
	else
		WARN_ON(1);

Thanks
Nic

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ