Re: [PATCH] fix race in AF_UNIX

3 messages, 3 authors, 2007-06-18 · open the first message on its own page

Re: [PATCH] fix race in AF_UNIX

From: Miklos Szeredi <miklos@szeredi.hu>
Date: 2007-06-18 10:40:09

* Miklos Szeredi [off-list ref] 2007-06-18 11:44
quoted
Garbage collection only ever happens, if the app is sending AF_UNIX
sockets over AF_UNIX sockets.  Which is a rather rare case.  And which
is basically why this bug went unnoticed for so long.

So my second patch only affects the performance of _exactly_ those
apps which might well be bitten by the bug itself.
That's not entirely the truth. It affects all applications using
AF_UNIX sockets while file descriptors are being transfered. I
agree that the performance impact is not severe on most systems
but if file descriptors are being transfered continously by just
a single application it can become rather severe.
You are wrong.  Look in unix_release_sock():

	if (atomic_read(&unix_tot_inflight))
		unix_gc();		/* Garbage collect fds */


unix_tot_inflight is the number of AF_UNIX sockets currently being
transferred over some AF_UNIX sockets.

That means that just sending (non-unix socket) fds over unix sockets
will never invoke the gc.

Miklos

Re: [PATCH] fix race in AF_UNIX

From: Thomas Graf <tgraf@suug.ch>
Date: 2007-06-18 10:43:29

* Miklos Szeredi [off-list ref] 2007-06-18 12:39
You are wrong.  Look in unix_release_sock():

	if (atomic_read(&unix_tot_inflight))
		unix_gc();		/* Garbage collect fds */


unix_tot_inflight is the number of AF_UNIX sockets currently being
transferred over some AF_UNIX sockets.

That means that just sending (non-unix socket) fds over unix sockets
will never invoke the gc.
That's what I meant, I'm sorry, I should have written unix socket
file descriptor to not leave any room for misinterpretation.

Re: [PATCH] fix race in AF_UNIX

From: Alan Cox <hidden>
Date: 2007-06-18 11:57:04

On Mon, 18 Jun 2007 12:43:40 +0200
Thomas Graf [off-list ref] wrote:
* Miklos Szeredi [off-list ref] 2007-06-18 12:39
quoted
You are wrong.  Look in unix_release_sock():

	if (atomic_read(&unix_tot_inflight))
		unix_gc();		/* Garbage collect fds */


unix_tot_inflight is the number of AF_UNIX sockets currently being
transferred over some AF_UNIX sockets.

That means that just sending (non-unix socket) fds over unix sockets
will never invoke the gc.
That's what I meant, I'm sorry, I should have written unix socket
file descriptor to not leave any room for misinterpretation.
You can bound the worst case on this and I think stay within the specs
(as the specs don't say a lot about it). One way would be to make
unix_gc() kick off a thread/tasklet and if the last unix_gc was within 5
seconds then use a timer to defer it - that prevents any user driven
"lets cause a ton of gc" cases.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help