linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	paulus@samba.org, ambrose@google.com, eric.dumazet@gmail.com
Subject: Re: [PATCH net-next] af_unix: fix a fatal race with bit fields
Date: Wed, 01 May 2013 18:08:05 +1000	[thread overview]
Message-ID: <1367395685.22115.19.camel@pasglop> (raw)
In-Reply-To: <20130501.033650.703182794549888825.davem@davemloft.net>

On Wed, 2013-05-01 at 03:36 -0400, David Miller wrote:
> From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Date: Wed, 01 May 2013 11:39:53 +1000
> 
> > I'm not even completely certain bytes are safe to be honest, though
> > probably more than bitfields. I'll poke our compiler people.
> 
> Older Alpha only has 32-bit and 64-bit loads and stores, so byte sized
> accesses are not atomic, and therefore use racey read-modify-write
> sequences.

In this case it depends whether the compiler will "chose" the smaller
(32-bit) size which hopefully won't overlap with the atomic/lock
provided the latter is aligned... lots of if's here, makes me nervous...

At least the bytes seem to fix it for ppc64 so far...

It would make feel generally better if we could get gcc to guarantee us
to always use the smallest access size that encompass the whole bitfield
(or at least not go larger than int when the bitfield is defined as
unsigned int). This would take care of all the cases we haven't spotted
yet (hopefully).

For all intend and purposes those two fields are bits of an unsigned
int, why the heck would the compiler use a larger access size anyway ? I
seem to recall that we have other places where such an assumption is
made that ints are accessed atomically, and Linus stating in the past
that a compiler doing anything else was not worth bothering with. I
don't see why bitfields of such int would be an exception to that rule
(though again, this is probably not a rule stated in the standard ... oh
well).

/me goes have a glass of wine and not think about this until tomorrow.

Cheers,
Ben.

  reply	other threads:[~2013-05-01  8:08 UTC|newest]

Thread overview: 23+ 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:39 ` Benjamin Herrenschmidt
2013-05-01  7:36   ` David Miller
2013-05-01  8:08     ` Benjamin Herrenschmidt [this message]
2013-05-01 15:24     ` [PATCH v2 " Eric Dumazet
2013-05-01 15:53       ` David Laight
2013-05-01 16:00         ` Eric Dumazet
2013-05-01 19:14       ` David Miller
2013-05-01 12:08   ` [PATCH " Ben Hutchings
2013-05-03 14:29   ` David Laight
2013-05-03 15:02     ` Eric Dumazet
2013-05-03 15:44       ` David Laight
2013-05-01  1:51 ` Anton Blanchard
2013-05-01  2:24   ` Eric Dumazet
2013-05-01  3:54     ` Alan Modra
2013-05-01  5:04       ` Eric Dumazet
2013-05-01 15:10         ` Stephen Hemminger
2013-05-02 21:11           ` Benjamin Herrenschmidt
2013-05-03  1:31         ` Alan Modra
2013-05-03  8:20           ` David Laight
2013-05-03 12:57           ` Benjamin Herrenschmidt
2013-05-03 14:14           ` Eric Dumazet
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=1367395685.22115.19.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=ambrose@google.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 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).