Thread (8 messages) flat view 8 messages, 5 authors, 2015-08-25

Re: [PATCH] usbnet: Fix two races between usbnet_stop() and the BH

From: Alan Stern <hidden>
Date: 2015-08-24 18:06:18
Also in: lkml

On Mon, 24 Aug 2015, David Miller wrote:
From: Eugene Shatokhin <redacted>
Date: Wed, 19 Aug 2015 14:59:01 +0300
quoted
So the following might be possible, although unlikely:

CPU0             CPU1
                 clear_bit: read dev->flags
                 clear_bit: clear EVENT_RX_KILL in the read value

dev->flags=0;

                 clear_bit: write updated dev->flags

As a result, dev->flags may become non-zero again.
Is this really possible?

Stores really are "atomic" in the sense that the do their update
in one indivisible operation.
Provided you use ACCESS_ONCE or WRITE_ONCE or whatever people like to 
call it now.
Atomic operations like clear_bit also will behave that way.
Are you certain about that?  I couldn't find any mention of it in
Documentation/atomic_ops.txt.

In theory, an architecture could implement atomic bit operations using 
a spinlock to insure atomicity.  I don't know if any architectures do 
this, but if they do then the scenario above could arise.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help