Re: [PATCH -mm -next] ipc,sem: untangle RCU locking with find_alloc_undo

From: Rik van Riel
Date: Sat Mar 30 2013 - 21:30:35 EST


On 03/30/2013 09:35 AM, Sasha Levin wrote:

I'm thinking that the solution is as simple as:

Your patch is absolutely correct. All it needs now is your
signed-off-by, so Andrew can merge it into -mm :)

Reviewed-by: Rik van Riel <riel@xxxxxxxxxx>

diff --git a/ipc/sem.c b/ipc/sem.c
index 6e109ef..ac36671 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -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];

But I'm not 100% sure if I don't mess up anything else.

I checked the surrounding code, it all looks fine.

--
All rights reversed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/