Skip to contentSkip to conversation

ipc,sem: prevent releasing RCU read lock twice in semctl_main

PATCH New Sasha Levin 1 participant 1 message Apr 1, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipc,sem: prevent releasing RCU read lock twice in semctl_main

We will release RCU read lock twice if the sem id passed from userspace is not within the legal range in semctl_main.

---
 ipc/sem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
ipc/sem.c +4 -2
index 6e109ef..ac36671 100644
@@ -1333,8 +1333,10 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
 	/* GETVAL, GETPID, GETNCTN, GETZCNT: fall-through */
 	}
 	err = -EINVAL;
-	if(semnum < 0 || semnum >= nsems)
-		goto out_unlock;
+	if(semnum < 0 || semnum >= nsems) {
+		rcu_read_unlock();
+		goto out_wakeup;
+	}
 
 	sem_lock(sma, NULL, -1);
 	curr = &sma->sem_base[semnum];
Signature · 1 line
1.8.1.5