|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [patch-4.16] arm/smmuv1,v2: Protect smmu master list with a lock
Hi Michal, On 26/10/2021 13:29, Michal Orzel wrote: If a device is added to SMMUv1/v2 from DT and PCI at the same time, there is a concurrent access to a smmu master list. This could lead to a scenario where one is looking into a list that is being modified at the same time. Add a lock to prevent this issue. Did you intend to say "Hold" rather than "Add"? Reuse the existing spinlock arm_smmu_devices_lock as it is already protecting find_smmu_master. ipmmu-smmu and smmuv3 are not impacted by this issue as there is no access or modification of a global resource during add_device. Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx> --- This patch aims for 4.16 release. Benefits: Remove a bug that could lead to a corruption of the smmu master list, which would be very hard to debug. From my understanding, this corruption would only happen with CONFIG_HAS_PCI. At the moment, this is a experimental feature as it is not fully complete. Risks: Overall the risk is low as we are touching init code rather than a runtime one. In case of any issue, the problem would be catched during system boot or guest start. With the PCI feature enabled, this can be called at runtime as this plumbed through a PHYSDEVOP. That said, it doesn't matter here as for supported code (platform/DT device), this will only happen during boot. The patch looks straighforward, so I would not mind to have it in Xen 4.16. Ian, what do you think?
Please add a newline here. + return ret; }static int register_smmu_master(struct arm_smmu_device *smmu, At the moment, unlocking here is fine because we don't remove the device. However, there are a series to supporting removing a device (see [1]). So I think it would be preferable to unlock after the last use of 'cfg'. Looking at the code, I also noticed that the error path is not correct for at least the PCI device and we would leak memory. We also assume that Stream ID == Requester ID. Are both of them in your radar for PCI passthrough? Cheers,[1] https://lore.kernel.org/xen-devel/1630562763-390068-9-git-send-email-fnu.vikram@xxxxxxxxxx/ -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |