Skip to contentSkip to conversation

add missing memory barriers to ipc/sem.c

PATCH In review Manfred Spraul 2 participants 2 messages Dec 23, 2005 – Dec 24, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add missing memory barriers to ipc/sem.c

Hi Linus,

Two smp_wmb() statements are missing in the sysv sem code: This could cause stack corruptions. The attached patch adds them.

ipc/sem.c +2 -0
@@ -381,6 +381,7 @@
 			/* hands-off: q will disappear immediately after
 			 * writing q->status.
 			 */
+			smb_wmb();
 			q->status = error;
 			q = n;
 		} else {
@@ -461,6 +462,7 @@
 		n = q->next;
 		q->status = IN_WAKEUP;
 		wake_up_process(q->sleeper); /* doesn't sleep */
+		smp_wmb();
 		q->status = -EIDRM;	/* hands-off q */
 		q = n;
 	}
#1 lore raw
Quoted 13 lines · Manfred Spraul

Hi Linus,

Two smp_wmb() statements are missing in the sysv sem code: This could cause stack corruptions. The attached patch adds them.

------------------------------------------------------------------------

ipc/sem.c line 384

Quoted 4 lines
ipc/sem.c +1 -0
@@ -381,6 +381,7 @@
 			/* hands-off: q will disappear immediately after
 			 * writing q->status.
 			 */
+			smb_wmb();

Typo? Shouldn't it be smp_wmb();

Quoted 11 lines
ipc/sem.c +1 -0
 			q->status = error;
 			q = n;
 		} else {
@@ -461,6 +462,7 @@
 		n = q->next;
 		q->status = IN_WAKEUP;
 		wake_up_process(q->sleeper); /* doesn't sleep */
+		smp_wmb();
 		q->status = -EIDRM;	/* hands-off q */
 		q = n;
 	}