From: Davidlohr Bueso Date: Thu, 26 Jul 2018 23:37:19 +0000 (-0700) Subject: ipc/sem.c: prevent queue.status tearing in semop X-Git-Tag: v4.19~556^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f075faa300acc4f6301e348acde0a4580ed5f77c;p=platform%2Fkernel%2Flinux-rpi.git ipc/sem.c: prevent queue.status tearing in semop In order for load/store tearing prevention to work, _all_ accesses to the variable in question need to be done around READ and WRITE_ONCE() macros. Ensure everyone does so for q->status variable for semtimedop(). Link: http://lkml.kernel.org/r/20180717052654.676-1-dave@stgolabs.net Signed-off-by: Davidlohr Bueso Cc: Manfred Spraul Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/ipc/sem.c b/ipc/sem.c index 5af1943..76e95e4 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -2118,7 +2118,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops, } do { - queue.status = -EINTR; + WRITE_ONCE(queue.status, -EINTR); queue.sleeper = current; __set_current_state(TASK_INTERRUPTIBLE);