2001-02-19 16:41:05

by Hugh Dickins

[permalink] [raw]
Subject: [PATCH] sys_semop() EIDRM BUG fix

sys_semop() is wrong to insist that queue.status be -EIDRM when
sem_lock() fails on awakening. It is quite normal for update_queue()
to have set status 0, removed process from queue and woken it; but
IPC_RMID come in before that process gets to run (or to lock) -
since process already off queue, its status is not set to -EIDRM.
If we want a safety check here, check removed from queue instead.
Return original status or -EIDRM? Checked other OSes, use -EIDRM.

diff -urN linux-2.4.2-pre4/ipc/sem.c linux/ipc/sem.c
--- linux-2.4.2-pre4/ipc/sem.c Sat Feb 17 11:14:27 2001
+++ linux/ipc/sem.c Sun Feb 18 08:21:37 2001
@@ -922,7 +922,7 @@

tmp = sem_lock(semid);
if(tmp==NULL) {
- if(queue.status != -EIDRM)
+ if(queue.prev != NULL)
BUG();
current->semsleeping = NULL;
error = -EIDRM;