[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151022060304.GQ22011@ZenIV.linux.org.uk>
Date: Thu, 22 Oct 2015 07:03:04 +0100
From: Al Viro <viro@...IV.linux.org.uk>
To: Alan Burlison <Alan.Burlison@...cle.com>
Cc: David Miller <davem@...emloft.net>, eric.dumazet@...il.com,
stephen@...workplumber.org, netdev@...r.kernel.org,
dholland-tech@...bsd.org, casper.dik@...cle.com
Subject: Re: [Bug 106241] New: shutdown(3)/close(3) behaviour is incorrect
for sockets in accept(3)
On Thu, Oct 22, 2015 at 05:44:58AM +0100, Al Viro wrote:
> Except that in this case "correctness" is the matter of rather obscure and
> ill-documented areas in POSIX. Don't get me wrong - this semantics isn't
> inherently bad, but it's nowhere near being an absolute requirement.
PS: in principle, a fairly ugly trick might suffice for accept(2), but
I'm less than happy with going there. Namely, we could
* have ->accept() get descriptor number
* have ->flush() get descriptor number in addition to current->files
and have it DTRT for sockets in the middle of accept(2).
However, in addition to being ugly as hell, it has the problem with the points
where we call ->flush(), specifically do_dup2() and __close_fd().
It's done *after* the replacement/removal from descriptor table, so another
socket might have already gotten the same descriptor and we'd get spurious
termination of accept(2).
And I'm really curious about the things Solaris would do with dup2() there.
Does it take into account the possibility of new accept() coming just as
dup2() is trying to terminate the ongoing ones? Is there a window when
descriptor-to-file lookups would fail? Looks like a race/deadlock country...
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists