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: <BN9PR11MB527629DEF740C909A7B7BEB38CB49@BN9PR11MB5276.namprd11.prod.outlook.com>
Date:   Fri, 24 Jun 2022 06:16:10 +0000
From:   "Tian, Kevin" <kevin.tian@...el.com>
To:     Yong Wu <yong.wu@...iatek.com>, Nicolin Chen <nicolinc@...dia.com>,
        "Baolu Lu" <baolu.lu@...ux.intel.com>
CC:     "linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
        "cohuck@...hat.com" <cohuck@...hat.com>,
        "jordan@...micpenguin.net" <jordan@...micpenguin.net>,
        "linux-tegra@...r.kernel.org" <linux-tegra@...r.kernel.org>,
        "thierry.reding@...il.com" <thierry.reding@...il.com>,
        "will@...nel.org" <will@...nel.org>,
        "alyssa@...enzweig.io" <alyssa@...enzweig.io>,
        "jean-philippe@...aro.org" <jean-philippe@...aro.org>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "zhang.lyra@...il.com" <zhang.lyra@...il.com>,
        "iommu@...ts.linux-foundation.org" <iommu@...ts.linux-foundation.org>,
        "jonathanh@...dia.com" <jonathanh@...dia.com>,
        "jgg@...dia.com" <jgg@...dia.com>,
        "yangyingliang@...wei.com" <yangyingliang@...wei.com>,
        "orsonzhai@...il.com" <orsonzhai@...il.com>,
        "gerald.schaefer@...ux.ibm.com" <gerald.schaefer@...ux.ibm.com>,
        "linux-arm-msm@...r.kernel.org" <linux-arm-msm@...r.kernel.org>,
        "alex.williamson@...hat.com" <alex.williamson@...hat.com>,
        "christophe.jaillet@...adoo.fr" <christophe.jaillet@...adoo.fr>,
        "matthias.bgg@...il.com" <matthias.bgg@...il.com>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "virtualization@...ts.linux-foundation.org" 
        <virtualization@...ts.linux-foundation.org>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        "dwmw2@...radead.org" <dwmw2@...radead.org>,
        "marcan@...can.st" <marcan@...can.st>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "baolin.wang7@...il.com" <baolin.wang7@...il.com>,
        "linux-mediatek@...ts.infradead.org" 
        <linux-mediatek@...ts.infradead.org>,
        "robin.murphy@....com" <robin.murphy@....com>
Subject: RE: [PATCH v3 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain
 and device/group

> From: Yong Wu
> Sent: Friday, June 24, 2022 1:39 PM
> 
> On Thu, 2022-06-23 at 19:44 -0700, Nicolin Chen wrote:
> > On Fri, Jun 24, 2022 at 09:35:49AM +0800, Baolu Lu wrote:
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > On 2022/6/24 04:00, Nicolin Chen wrote:
> > > > diff --git a/drivers/iommu/mtk_iommu_v1.c
> > > > b/drivers/iommu/mtk_iommu_v1.c
> > > > index e1cb51b9866c..5386d889429d 100644
> > > > --- a/drivers/iommu/mtk_iommu_v1.c
> > > > +++ b/drivers/iommu/mtk_iommu_v1.c
> > > > @@ -304,7 +304,7 @@ static int mtk_iommu_v1_attach_device(struct
> > > > iommu_domain *domain, struct device
> > > >       /* Only allow the domain created internally. */
> > > >       mtk_mapping = data->mapping;
> > > >       if (mtk_mapping->domain != domain)
> > > > -             return 0;
> > > > +             return -EMEDIUMTYPE;
> > > >
> > > >       if (!data->m4u_dom) {
> > > >               data->m4u_dom = dom;
> > >
> > > This change looks odd. It turns the return value from success to
> > > failure. Is it a bug? If so, it should go through a separated fix
> > > patch.
> 
> Thanks for the review:)
> 
> >
> > Makes sense.
> >
> > I read the commit log of the original change:
> >
> https://lore.kernel.org/r/1589530123-30240-1-git-send-email-
> yong.wu@...iatek.com
> >
> > It doesn't seem to allow devices to get attached to different
> > domains other than the shared mapping->domain, created in the
> > in the mtk_iommu_probe_device(). So it looks like returning 0
> > is intentional. Though I am still very confused by this return
> > value here, I doubt it has ever been used in a VFIO context.
> 
> It's not used in VFIO context. "return 0" just satisfy the iommu
> framework to go ahead. and yes, here we only allow the shared "mapping-
> >domain" (All the devices share a domain created internally).
> 
> thus I think we should still keep "return 0" here.
> 

What prevent this driver from being used in VFIO context?

and why would we want to go ahead when an obvious error occurs
i.e. when a device is attached to an unexpected domain?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ