From: Anton Blanchard <anton@samba.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: amodra@gmail.com, netdev <netdev@vger.kernel.org>,
Ambrose Feinstein <ambrose@google.com>,
Paul Mackerras <paulus@samba.org>,
linuxppc-dev@lists.ozlabs.org, David Miller <davem@davemloft.net>
Subject: Re: [PATCH net-next] af_unix: fix a fatal race with bit fields
Date: Wed, 1 May 2013 11:51:03 +1000 [thread overview]
Message-ID: <20130501115103.58e40f37@kryten> (raw)
In-Reply-To: <1367370761.11020.22.camel@edumazet-glaptop>
Hi Eric,
> From: Eric Dumazet <edumazet@google.com>
>
> Using bit fields is dangerous on ppc64, as the compiler uses 64bit
> instructions to manipulate them. If the 64bit word includes any
> atomic_t or spinlock_t, we can lose critical concurrent changes.
>
> This is happening in af_unix, where unix_sk(sk)->gc_candidate/
> gc_maybe_cycle/lock share the same 64bit word.
>
> This leads to fatal deadlock, as one/several cpus spin forever
> on a spinlock that will never be available again.
I just spoke to Alan Modra and he suspects this is a compiler
bug. Can you give us your compiler version info?
Anton
> Reported-by: Ambrose Feinstein <ambrose@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> ---
>
> Could ppc64 experts confirm using byte is safe, or should we really
> add a 32bit hole after the spinlock ? If so, I wonder how many other
> places need a change...
>
> include/net/af_unix.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/net/af_unix.h b/include/net/af_unix.h
> index a8836e8..4520a23f 100644
> --- a/include/net/af_unix.h
> +++ b/include/net/af_unix.h
> @@ -57,8 +57,8 @@ struct unix_sock {
> struct list_head link;
> atomic_long_t inflight;
> spinlock_t lock;
> - unsigned int gc_candidate : 1;
> - unsigned int gc_maybe_cycle : 1;
> + unsigned char gc_candidate;
> + unsigned char gc_maybe_cycle;
> unsigned char recursion_level;
> struct socket_wq peer_wq;
> };
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
WARNING: multiple messages have this Message-ID (diff)
From: Anton Blanchard <anton@samba.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>,
linuxppc-dev@lists.ozlabs.org, Paul Mackerras <paulus@samba.org>,
Ambrose Feinstein <ambrose@google.com>,
amodra@gmail.com
Subject: Re: [PATCH net-next] af_unix: fix a fatal race with bit fields
Date: Wed, 1 May 2013 11:51:03 +1000 [thread overview]
Message-ID: <20130501115103.58e40f37@kryten> (raw)
In-Reply-To: <1367370761.11020.22.camel@edumazet-glaptop>
Hi Eric,
> From: Eric Dumazet <edumazet@google.com>
>
> Using bit fields is dangerous on ppc64, as the compiler uses 64bit
> instructions to manipulate them. If the 64bit word includes any
> atomic_t or spinlock_t, we can lose critical concurrent changes.
>
> This is happening in af_unix, where unix_sk(sk)->gc_candidate/
> gc_maybe_cycle/lock share the same 64bit word.
>
> This leads to fatal deadlock, as one/several cpus spin forever
> on a spinlock that will never be available again.
I just spoke to Alan Modra and he suspects this is a compiler
bug. Can you give us your compiler version info?
Anton
> Reported-by: Ambrose Feinstein <ambrose@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> ---
>
> Could ppc64 experts confirm using byte is safe, or should we really
> add a 32bit hole after the spinlock ? If so, I wonder how many other
> places need a change...
>
> include/net/af_unix.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/net/af_unix.h b/include/net/af_unix.h
> index a8836e8..4520a23f 100644
> --- a/include/net/af_unix.h
> +++ b/include/net/af_unix.h
> @@ -57,8 +57,8 @@ struct unix_sock {
> struct list_head link;
> atomic_long_t inflight;
> spinlock_t lock;
> - unsigned int gc_candidate : 1;
> - unsigned int gc_maybe_cycle : 1;
> + unsigned char gc_candidate;
> + unsigned char gc_maybe_cycle;
> unsigned char recursion_level;
> struct socket_wq peer_wq;
> };
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
next prev parent reply other threads:[~2013-05-01 1:51 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-01 1:12 [PATCH net-next] af_unix: fix a fatal race with bit fields Eric Dumazet
2013-05-01 1:12 ` Eric Dumazet
2013-05-01 1:39 ` Benjamin Herrenschmidt
2013-05-01 1:39 ` Benjamin Herrenschmidt
2013-05-01 7:36 ` David Miller
2013-05-01 7:36 ` David Miller
2013-05-01 8:08 ` Benjamin Herrenschmidt
2013-05-01 15:24 ` [PATCH v2 " Eric Dumazet
2013-05-01 15:24 ` Eric Dumazet
2013-05-01 15:53 ` David Laight
2013-05-01 15:53 ` David Laight
2013-05-01 16:00 ` Eric Dumazet
2013-05-01 16:00 ` Eric Dumazet
2013-05-01 19:14 ` David Miller
2013-05-01 19:14 ` David Miller
2013-05-01 12:08 ` [PATCH " Ben Hutchings
2013-05-01 12:08 ` Ben Hutchings
2013-05-03 14:29 ` David Laight
2013-05-03 14:29 ` David Laight
2013-05-03 15:02 ` Eric Dumazet
2013-05-03 15:02 ` Eric Dumazet
2013-05-03 15:44 ` David Laight
2013-05-03 15:44 ` David Laight
2013-05-01 1:51 ` Anton Blanchard [this message]
2013-05-01 1:51 ` Anton Blanchard
2013-05-01 2:24 ` Eric Dumazet
2013-05-01 2:24 ` Eric Dumazet
2013-05-01 3:54 ` Alan Modra
2013-05-01 3:54 ` Alan Modra
2013-05-01 5:04 ` Eric Dumazet
2013-05-01 5:04 ` Eric Dumazet
2013-05-01 15:10 ` Stephen Hemminger
2013-05-01 15:10 ` Stephen Hemminger
2013-05-02 21:11 ` Benjamin Herrenschmidt
2013-05-02 21:11 ` Benjamin Herrenschmidt
2013-05-03 1:31 ` Alan Modra
2013-05-03 1:31 ` Alan Modra
2013-05-03 8:20 ` David Laight
2013-05-03 8:20 ` David Laight
2013-05-03 12:57 ` Benjamin Herrenschmidt
2013-05-03 14:14 ` Eric Dumazet
2013-05-03 14:14 ` Eric Dumazet
2013-05-02 17:02 ` Scott Wood
2013-05-02 17:02 ` Scott Wood
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=20130501115103.58e40f37@kryten \
--to=anton@samba.org \
--cc=ambrose@google.com \
--cc=amodra@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=paulus@samba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.