On Thu, Jan 19, 2017 at 07:14:59PM +1000, Martin Pieuchot wrote:
> Turns out that the NET_LOCK() related hang reported by many is a
> deadlock. One way to prevent it is to ensure that fdplock() is
> always taken before the NET_LOCK() when both have to been hold.
>
> This generates the diff below.
>
> Comments, ok?
unp_externalize() does mostly file system operations, so it does
not need the netlock. But there is one call to unp_discard(). Do
we consider unix domain sockets part of the network stack? As all
functions are running in syscall context with kernel lock, it does
not really matter. There is nothing that has to be protected in
unp_discard().
> if (pr->pr_domain->dom_externalize &&
> mtod(cm, struct cmsghdr *)->cmsg_type ==
> - SCM_RIGHTS)
> - error = (*pr->pr_domain->dom_externalize)(cm,
> - controllen, flags);
> + SCM_RIGHTS) {
> + NET_UNLOCK(s);
> + error = (*pr->pr_domain->dom_externalize)(
> + cm, controllen, flags);
> + NET_LOCK(s);
> + }
The body of the if block is 4 spaces too much left. That was wrong
before, but now the multiline condition and the multiline block
should not be on the same level. This way it would still fit
in 80 columns.
error =
(*pr->pr_domain->dom_externalize)
(cm, controllen, flags);
OK bluhm@