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] [day] [month] [year] [list]
Date:   Tue, 8 Nov 2022 09:23:10 -0400
From:   Jason Gunthorpe <jgg@...dia.com>
To:     Will Deacon <will@...nel.org>
Cc:     Nicolin Chen <nicolinc@...dia.com>, joro@...tes.org,
        robin.murphy@....com, kevin.tian@...el.com,
        quic_jjohnson@...cinc.com, suravee.suthikulpanit@....com,
        robdclark@...il.com, dwmw2@...radead.org, baolu.lu@...ux.intel.com,
        yong.wu@...iatek.com, matthias.bgg@...il.com, orsonzhai@...il.com,
        baolin.wang@...ux.alibaba.com, zhang.lyra@...il.com,
        thierry.reding@...il.com, vdumpa@...dia.com, jonathanh@...dia.com,
        jean-philippe@...aro.org, tglx@...utronix.de,
        shameerali.kolothum.thodi@...wei.com,
        christophe.jaillet@...adoo.fr, yangyicong@...ilicon.com,
        yangyingliang@...wei.com, quic_saipraka@...cinc.com,
        jon@...id-run.com, iommu@...ts.linux.dev,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-arm-msm@...r.kernel.org, linux-mediatek@...ts.infradead.org,
        linux-tegra@...r.kernel.org,
        virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH v7 4/5] iommu: Use EINVAL for incompatible device/domain
 in ->attach_dev

On Tue, Nov 08, 2022 at 01:20:42PM +0000, Will Deacon wrote:
> On Mon, Nov 07, 2022 at 04:14:32PM -0800, Nicolin Chen wrote:
> > On Mon, Nov 07, 2022 at 03:26:45PM +0000, Will Deacon wrote:
> > 
> > > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > index ba47c73f5b8c..01fd7df16cb9 100644
> > > > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > @@ -2430,23 +2430,14 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
> > > >                       goto out_unlock;
> > > >               }
> > > >       } else if (smmu_domain->smmu != smmu) {
> > > > -             dev_err(dev,
> > > > -                     "cannot attach to SMMU %s (upstream of %s)\n",
> > > > -                     dev_name(smmu_domain->smmu->dev),
> > > > -                     dev_name(smmu->dev));
> > > > -             ret = -ENXIO;
> > > > +             ret = -EINVAL;
> > > >               goto out_unlock;
> > > >       } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
> > > >                  master->ssid_bits != smmu_domain->s1_cfg.s1cdmax) {
> > > > -             dev_err(dev,
> > > > -                     "cannot attach to incompatible domain (%u SSID bits != %u)\n",
> > > > -                     smmu_domain->s1_cfg.s1cdmax, master->ssid_bits);
> > > >               ret = -EINVAL;
> > > >               goto out_unlock;
> > > >       } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
> > > >                  smmu_domain->stall_enabled != master->stall_enabled) {
> > > > -             dev_err(dev, "cannot attach to stall-%s domain\n",
> > > > -                     smmu_domain->stall_enabled ? "enabled" : "disabled");
> > > >               ret = -EINVAL;
> > > >               goto out_unlock;
> > > >       }
> > 
> > > I think it would be helpful to preserve these messages using
> > > dev_err_ratelimited() so that attach failure can be diagnosed without
> > > having to hack the messages back into the driver.
> > 
> > Thank you for the review.
> > 
> > The change is already picked up last week. Yet, I can add prints
> > back with a followup patch, if no one has a problem with that.
> 
> Sorry, I fell behind with upstream so I got to this late. A patch on top
> would be fantastic!
> 
> > Also, I am not quite sure what the use case would be to have an
> > error print. Perhaps dev_dbg() would be more fitting if it is
> > just for diagnosis?
> 
> Sure, that works for me. I think the messages are useful for folks
> triggering this path e.g. via sysfs but if they're limited to debug I think
> that's better than removing them altogether.

I suspsect it has to be dbg - vfio/iommufd will probably trigger these
messages as it probes for domains that are compatible - eg certainly
the first one. Even if it is a "once" it would still emit a confusing
message for a normal occurance.

This is why they were removed in the first place..

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ