Re: [PATCH v2] vfio: Follow a strict lifetime for struct iommu_group

Jason Gunthorpe
2022-10-05T13:57:34Z

On Wed, Oct 05, 2022 at 09:46:45AM -0400, Matthew Rosato wrote:

> (again, with the follow-up applied) Besides the panic above I just
> noticed there is also this warning that immediately precedes and is
> perhaps more useful. Re: what triggers the WARN, both group->owner
> and group->owner_cnt are already 0

And this is after the 2nd try that fixes the locking?

This shows that vfio_group_detach_container() is called twice (which
was my guess), hoever this looks to be impossible as both calls are
protected by 'if (group->container)' and the function NULL's
group->container and it is all under the proper lock.

My guess was that missing locking caused the two cases to race and
trigger WARN, but the locking should fix that.

So I'm at a loss, can you investigate a bit?

Jason