diff options
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/sem.c | 29 |
1 files changed, 8 insertions, 21 deletions
@@ -328,28 +328,12 @@ static inline void sem_lock_and_putref(struct sem_array *sma) | |||
328 | ipc_rcu_putref(sma); | 328 | ipc_rcu_putref(sma); |
329 | } | 329 | } |
330 | 330 | ||
331 | static inline void sem_getref_and_unlock(struct sem_array *sma) | ||
332 | { | ||
333 | WARN_ON_ONCE(!ipc_rcu_getref(sma)); | ||
334 | sem_unlock(sma, -1); | ||
335 | } | ||
336 | |||
337 | static inline void sem_putref(struct sem_array *sma) | 331 | static inline void sem_putref(struct sem_array *sma) |
338 | { | 332 | { |
339 | sem_lock_and_putref(sma); | 333 | sem_lock_and_putref(sma); |
340 | sem_unlock(sma, -1); | 334 | sem_unlock(sma, -1); |
341 | } | 335 | } |
342 | 336 | ||
343 | /* | ||
344 | * Call inside the rcu read section. | ||
345 | */ | ||
346 | static inline void sem_getref(struct sem_array *sma) | ||
347 | { | ||
348 | sem_lock(sma, NULL, -1); | ||
349 | WARN_ON_ONCE(!ipc_rcu_getref(sma)); | ||
350 | sem_unlock(sma, -1); | ||
351 | } | ||
352 | |||
353 | static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s) | 337 | static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s) |
354 | { | 338 | { |
355 | ipc_rmid(&sem_ids(ns), &s->sem_perm); | 339 | ipc_rmid(&sem_ids(ns), &s->sem_perm); |
@@ -1116,9 +1100,14 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
1116 | ushort __user *array = p; | 1100 | ushort __user *array = p; |
1117 | int i; | 1101 | int i; |
1118 | 1102 | ||
1103 | sem_lock(sma, NULL, -1); | ||
1119 | if(nsems > SEMMSL_FAST) { | 1104 | if(nsems > SEMMSL_FAST) { |
1120 | sem_getref(sma); | 1105 | if (!ipc_rcu_getref(sma)) { |
1121 | 1106 | sem_unlock(sma, -1); | |
1107 | err = -EIDRM; | ||
1108 | goto out_free; | ||
1109 | } | ||
1110 | sem_unlock(sma, -1); | ||
1122 | sem_io = ipc_alloc(sizeof(ushort)*nsems); | 1111 | sem_io = ipc_alloc(sizeof(ushort)*nsems); |
1123 | if(sem_io == NULL) { | 1112 | if(sem_io == NULL) { |
1124 | sem_putref(sma); | 1113 | sem_putref(sma); |
@@ -1131,9 +1120,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
1131 | err = -EIDRM; | 1120 | err = -EIDRM; |
1132 | goto out_free; | 1121 | goto out_free; |
1133 | } | 1122 | } |
1134 | } else | 1123 | } |
1135 | sem_lock(sma, NULL, -1); | ||
1136 | |||
1137 | for (i = 0; i < sma->sem_nsems; i++) | 1124 | for (i = 0; i < sma->sem_nsems; i++) |
1138 | sem_io[i] = sma->sem_base[i].semval; | 1125 | sem_io[i] = sma->sem_base[i].semval; |
1139 | sem_unlock(sma, -1); | 1126 | sem_unlock(sma, -1); |