lkml.org 
[lkml]   [2014]   [Nov]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] n_tty: Add memory barrier to fix race condition in receive path
On Thu, Nov 06, 2014 at 12:39:59PM +0100, Christian Riesch wrote:
> The current implementation of put_tty_queue() causes a race condition
> when re-arranged by the compiler.
>
> On my build with gcc 4.8.3, cross-compiling for ARM, the line
>
> *read_buf_addr(ldata, ldata->read_head++) = c;
>
> was re-arranged by the compiler to something like
>
> x = ldata->read_head
> ldata->read_head++
> *read_buf_addr(ldata, x) = c;
>
> which causes a race condition. Invalid data is read if data is read
> before it is actually written to the read buffer.

Really? A compiler can rearange things like that and expect things to
actually work? How is that valid?

Is this the "broken gcc" version that ARM developers keep running into
all the time with odd crashes and problems? Can you upgrade to 4.9 and
see if that solves the issue for you?

thanks,

greg k-h


\
 
 \ /
  Last update: 2014-11-06 22:01    [W:0.055 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site