On Fri, 2018-07-06 at 15:16 +0200, Joerg Roedel wrote: > On Thu, Jun 21, 2018 at 07:08:20PM +0100, Dmitry Safonov wrote: > > find_iova() looks to be using a bad locking practice: it locks the > > returned iova only for the search time. And looking in code, the > > element can be removed from the tree and freed under rbtree lock. > > That > > happens during memory hot-unplug and cleanup on module > > removal. Here > > I cleanup users of the function and delete it. > > But this is only a problem if more than one code-path uses tries to > handle a given iova at the same time, no?
Yes, as far as I can see, there are code-paths which may try to handle it at the same time: o memory notifiers for hot-unplug (intel-iommu.c) o drivers unloading calls free_iova(), which in the result calls find_iova() o I see at least one driver that frees iova during it's normal work too: scif_rma.c:scif_free_window_offset() So, I decided to fix the interface while it's not widely used instead of all callers. Looks worth for me even as it's all corner-cases like unplugging the memory. Anyway, just found it while some college wrote a debug sysfs interface for iovas and used find_iova(). So, if you think it's not worth to change - that's fine for me, but I thought I'll nip this in the bud, preventing other people to misuse it. -- Thanks, Dmitry _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu