Initialize msg/shm IPC objects before doing ipc_addid() 63/154663/1
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 30 Sep 2015 16:48:40 +0000 (12:48 -0400)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 11 Oct 2017 04:02:16 +0000 (13:02 +0900)
commite6ecd836236e1c508ea227020be87a15fb22e790
tree149f69b8b7ccf0db966ef2892517fa8098aacad3
parent7bb482807d4f686487e9acaf43503e7d638f3dab
Initialize msg/shm IPC objects before doing ipc_addid()

commit b9a532277938798b53178d5a66af6e2915cb27cf upstream.

As reported by Dmitry Vyukov, we really shouldn't do ipc_addid() before
having initialized the IPC object state.  Yes, we initialize the IPC
object in a locked state, but with all the lockless RCU lookup work,
that IPC object lock no longer means that the state cannot be seen.

We already did this for the IPC semaphore code (see commit e8577d1f0329:
"ipc/sem.c: fully initialize sem_array before making it visible") but we
clearly forgot about msg and shm.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[sw0312.kim: cherry-pick from linux-3.10.y to fix CVE-2015-7613]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I6f398b1bf047a7937e84364e737bfcf391aec9fc
ipc/msg.c
ipc/shm.c
ipc/util.c