* the mystery that is sock_fasync
@ 2006-08-11 10:15 David Miller
2006-08-11 10:28 ` Evgeniy Polyakov
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: David Miller @ 2006-08-11 10:15 UTC (permalink / raw)
To: netdev
I was studying sock_fasync() and it definitely has a bunch
of questionable issues.
Well firstly, it duplicates fasync_helper() entirely.
The only difference is that sock_fasync() does socket
local locking which is better for performance. fasync_helper()
uses a global spinlock to protect the fasync list it is given.
Secondly, and I think more importantly, this thing acts as
if it is possible to have more than one file --> socket
mapping. That is simply impossible.
There can indeed be many file descriptors that point to the
file object that points to the socket inode, but that's
different.
This invariant is maintained by the fact that socket
creations creates and maps one file object to point
to the socket's inode in sock_create.
Furthermore we block any attempt to open sockets by name
via things like /proc/$PID/fds/$sock_fdnum
In fact when sock_close() runs, it calls sock_fasync(-1, file, 0) and
the subsequent sock_release() bug checks that fasync_list is NULL.
If my analysis is correct we can incredibly simplify sock_fasync().
Did I miss some way that multiple file objects can point to the
same socket inode?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: the mystery that is sock_fasync
2006-08-11 10:15 the mystery that is sock_fasync David Miller
@ 2006-08-11 10:28 ` Evgeniy Polyakov
2006-08-11 10:31 ` David Miller
2006-08-11 11:35 ` David Miller
2006-08-11 13:35 ` Alexey Kuznetsov
2 siblings, 1 reply; 5+ messages in thread
From: Evgeniy Polyakov @ 2006-08-11 10:28 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Fri, Aug 11, 2006 at 03:15:16AM -0700, David Miller (davem@davemloft.net) wrote:
> Did I miss some way that multiple file objects can point to the
> same socket inode?
What about dup and pipe?
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: the mystery that is sock_fasync
2006-08-11 10:28 ` Evgeniy Polyakov
@ 2006-08-11 10:31 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2006-08-11 10:31 UTC (permalink / raw)
To: johnpol; +Cc: netdev
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Date: Fri, 11 Aug 2006 14:28:20 +0400
> On Fri, Aug 11, 2006 at 03:15:16AM -0700, David Miller (davem@davemloft.net) wrote:
> > Did I miss some way that multiple file objects can point to the
> > same socket inode?
>
> What about dup and pipe?
Dup makes new "file descriptor" references to the file object.
It does not create a new file object reference to a socket inode,
which is what we're concerned with here.
Pipe files do not point to socket inodes.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: the mystery that is sock_fasync
2006-08-11 10:15 the mystery that is sock_fasync David Miller
2006-08-11 10:28 ` Evgeniy Polyakov
@ 2006-08-11 11:35 ` David Miller
2006-08-11 13:35 ` Alexey Kuznetsov
2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2006-08-11 11:35 UTC (permalink / raw)
To: netdev
From: David Miller <davem@davemloft.net>
Date: Fri, 11 Aug 2006 03:15:16 -0700 (PDT)
> If my analysis is correct we can incredibly simplify sock_fasync().
I've also found more bugs in sock_fasync(), it's a real can of worms
:-)
It deviates from the return value policies used by othe
file_ops->fasync() implementations. For example, if we look at
fasync_helper() it clearly shows that we should return 1 if a list
manipulation (insert of delete) happened else it should return 0.
Also, my theory about struct file<-->struct socket being a one-to-one
mapping is fully supported by the fact that struct socket has a "file"
member that can only take on one value.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: the mystery that is sock_fasync
2006-08-11 10:15 the mystery that is sock_fasync David Miller
2006-08-11 10:28 ` Evgeniy Polyakov
2006-08-11 11:35 ` David Miller
@ 2006-08-11 13:35 ` Alexey Kuznetsov
2 siblings, 0 replies; 5+ messages in thread
From: Alexey Kuznetsov @ 2006-08-11 13:35 UTC (permalink / raw)
To: David Miller; +Cc: netdev
Hello!
> Did I miss some way that multiple file objects can point to the
> same socket inode?
Absolutely prohibited. Always was.
Apparently, sock_fasync() was cloned from tty_fasync(), that's the only
reason why it is so creepy.
Alexey
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-08-11 13:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-11 10:15 the mystery that is sock_fasync David Miller
2006-08-11 10:28 ` Evgeniy Polyakov
2006-08-11 10:31 ` David Miller
2006-08-11 11:35 ` David Miller
2006-08-11 13:35 ` Alexey Kuznetsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).