Re: [PATCH 1/1] iommu: Avoid races around default domain allocations

From: Jason Gunthorpe
Date: Wed Feb 07 2024 - 20:13:41 EST


On Thu, Feb 08, 2024 at 12:04:44AM +0000, Robin Murphy wrote:
> > Frankly, I'd suggest just proposing the necessary (and tested)
> > upstream patches to 6.1, however large they are, and see what Greg and
> > Sasha say. This is the usual working model they have, as I understand
> > it.
>
> To be blunt, hell no. Stable is far enough from its namesake already; the
> ongoing bordering-on-ridiculous brokenness of your mainline changes where

What on earth are you even talking about? POWER?

> That said, I also don't think there would be any harm in applying this to
> mainline as a belt-and-braces thing either,

Really?

Now that you've made me look, this patch breaks the
iommu_group_store_type() flow both on latest and on v6.1 from what I
can see.

On v6.1:

iommu_change_dev_def_domain():

prev_dom = group->default_domain;
if (!prev_dom) {
ret = -EINVAL;
goto out;
}
[..]
/* Sets group->default_domain to the newly allocated domain */
ret = iommu_group_alloc_default_domain(dev->bus, group, type);
if (ret)
goto out;

But this patch changes iommu_group_alloc_default_domain() to succeed
always without doing anythiing.

So this patch needs some fixing.

There is a very good reason the stable people don't like boutique patches..

Jason