Re: possible deadlock in mon_bin_vma_fault

From: Pete Zaitcev
Date: Thu Nov 21 2019 - 11:47:01 EST


On Thu, 21 Nov 2019 11:20:20 -0500 (EST)
Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:

> On Thu, 21 Nov 2019, Pete Zaitcev wrote:
>
> > Anyway... If you are looking at it too, what do you think about not using
> > any locks in mon_bin_vma_fault() at all? Isn't it valid? I think I tried
> > to be "safe", but it only uses things that are constants unless we're
> > opening and closing; a process cannot make page faults unless it has
> > some thing mapped; and that is only possible if device is open and stays
> > open. Can you find a hole in this reasoning?
>
> I think you're right. But one thing concerns me: What happens if the
> same buffer is mapped by more than one process? Do you allow that?

Yes, we allow 2 processes reading from mmap in the same time.
They may miss events, but there should be no issue to the internal
consistency of any pointers in usbmon, and no crashes or deadlocks.
Also, we cannot prohibit that. Imagine a process that does open(),
mmap(), fork()/clone().

-- Pete