Re: possible deadlock in mon_bin_vma_fault

From: Pete Zaitcev
Date: Thu Nov 21 2019 - 09:48:50 EST


On Wed, 20 Nov 2019 13:47:00 -0500 (EST)
Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:

> > + if (rp->mmap_active)
> > + return -EBUSY;

> Like that, yes, but the test has to be made while fetch_lock is held.

Certainly, thanks. I was rushing just to add a postscriptum.

> Incidentally, the comment for fetch_lock says that it protects b_read
> and b_out, but mon_bin_vma_fault doesn't use either of those fields.

I probably should change that comment to "protect the integrity of the
circular buffer, such as b_out".

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?

-- Pete