From: David Miller <davem@davemloft.net>
To: miklos@szeredi.hu
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix race in AF_UNIX
Date: Tue, 05 Jun 2007 17:31:20 -0700 (PDT) [thread overview]
Message-ID: <20070605.173120.59467114.davem@davemloft.net> (raw)
In-Reply-To: <20070605.000247.18308209.davem@davemloft.net>
From: David Miller <davem@davemloft.net>
Date: Tue, 05 Jun 2007 00:02:47 -0700 (PDT)
> From: Miklos Szeredi <miklos@szeredi.hu>
> Date: Mon, 04 Jun 2007 11:45:32 +0200
>
> > > A recv() on an AF_UNIX, SOCK_STREAM socket can race with a
> > > send()+close() on the peer, causing recv() to return zero, even though
> > > the sent data should be received.
> > >
> > > This happens if the send() and the close() is performed between
> > > skb_dequeue() and checking sk->sk_shutdown in unix_stream_recvmsg():
> > >
> > > process A skb_dequeue() returns NULL, there's no data in the socket queue
> > > process B new data is inserted onto the queue by unix_stream_sendmsg()
> > > process B sk->sk_shutdown is set to SHUTDOWN_MASK by unix_release_sock()
> > > process A sk->sk_shutdown is checked, unix_release_sock() returns zero
> >
> > This is only part of the story. It turns out, there are other races
> > involving the garbage collector, that can throw away perfectly good
> > packets with AF_UNIX sockets in them.
> >
> > The problems arise when a socket goes from installed to in-flight or
> > vica versa during garbage collection. Since gc is done with a
> > spinlock held, this only shows up on SMP.
> >
> > The following patch fixes it for me, but it's possibly the wrong
> > approach.
> >
> > Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Concerning this specific patch I think we need to rethink it
a bit.
Holding a global mutex over recvmsg() calls under AF_UNIX is pretty
much a non-starter, this will kill performance for multi-threaded
apps.
One possible solution is for the garbage collection code to hold the
u->readlock while processing a socket, but be careful about deadlocks.
Anyone want to give that a try?
next prev parent reply other threads:[~2007-06-06 0:31 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-02 21:50 Miklos Szeredi
2007-06-02 22:11 ` Arnaldo Carvalho de Melo
2007-06-04 9:45 ` Miklos Szeredi
2007-06-05 7:02 ` David Miller
2007-06-05 7:42 ` Miklos Szeredi
2007-06-05 7:55 ` David Miller
2007-06-05 8:11 ` Miklos Szeredi
2007-06-05 8:19 ` David Miller
2007-06-05 20:11 ` David Miller
2007-06-06 0:31 ` David Miller [this message]
2007-06-06 5:26 ` Miklos Szeredi
2007-06-06 5:41 ` David Miller
2007-06-06 8:08 ` Miklos Szeredi
2007-06-06 8:12 ` David Miller
2007-06-08 1:47 ` David Miller
2007-06-11 9:57 ` Miklos Szeredi
2007-06-18 7:49 ` Miklos Szeredi
2007-06-18 7:57 ` David Miller
2007-06-18 8:20 ` Miklos Szeredi
2007-06-18 9:18 ` David Miller
2007-06-18 9:29 ` Miklos Szeredi
2007-06-18 9:35 ` David Miller
2007-06-18 9:44 ` Miklos Szeredi
2007-06-18 9:48 ` David Miller
2007-06-18 9:55 ` Miklos Szeredi
2007-06-18 9:59 ` David Miller
2007-06-18 10:32 ` Thomas Graf
2007-06-18 10:39 ` Miklos Szeredi
2007-06-18 10:43 ` Thomas Graf
2007-06-18 12:01 ` Alan Cox
2007-06-18 10:40 ` Thomas Graf
2007-06-18 10:47 ` Miklos Szeredi
2007-06-18 10:51 ` David Miller
2007-06-18 10:55 ` Miklos Szeredi
2007-06-18 11:02 ` David Miller
2007-06-18 11:06 ` Miklos Szeredi
2007-06-18 11:09 ` David Miller
2007-06-18 11:46 ` Miklos Szeredi
2007-06-18 11:47 ` Alan Cox
2007-06-18 11:45 ` Jan Engelhardt
2007-06-18 12:00 ` Miklos Szeredi
2007-06-21 15:18 ` Eric W. Biederman
2007-06-23 8:48 ` Miklos Szeredi
2007-06-23 16:42 ` Eric W. Biederman
2007-06-26 8:54 ` Miklos Szeredi
2007-06-26 15:24 ` Eric W. Biederman
2007-06-04 9:53 ` Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070605.173120.59467114.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®