~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to ipc/sem.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
#include <linux/rwsem.h>
87
87
#include <linux/nsproxy.h>
88
88
#include <linux/ipc_namespace.h>
89
 
#include <trace/ipc.h>
90
89
 
91
90
#include <asm/uaccess.h>
92
91
#include "util.h"
119
118
#define sc_semopm       sem_ctls[2]
120
119
#define sc_semmni       sem_ctls[3]
121
120
 
122
 
DEFINE_TRACE(ipc_sem_create);
123
 
 
124
121
void sem_init_ns(struct ipc_namespace *ns)
125
122
{
126
123
        ns->sc_semmsl = SEMMSL;
326
323
        struct ipc_namespace *ns;
327
324
        struct ipc_ops sem_ops;
328
325
        struct ipc_params sem_params;
329
 
        long err;
330
326
 
331
327
        ns = current->nsproxy->ipc_ns;
332
328
 
341
337
        sem_params.flg = semflg;
342
338
        sem_params.u.nsems = nsems;
343
339
 
344
 
        err = ipcget(ns, &sem_ids(ns), &sem_ops, &sem_params);
345
 
        trace_ipc_sem_create(err, semflg);
346
 
        return err;
 
340
        return ipcget(ns, &sem_ids(ns), &sem_ops, &sem_params);
347
341
}
348
342
 
349
343
/*
823
817
                }
824
818
 
825
819
                err = -EACCES;
826
 
                if (ipcperms (&sma->sem_perm, S_IRUGO))
 
820
                if (ipcperms(ns, &sma->sem_perm, S_IRUGO))
827
821
                        goto out_unlock;
828
822
 
829
823
                err = security_sem_semctl(sma, cmd);
868
862
        nsems = sma->sem_nsems;
869
863
 
870
864
        err = -EACCES;
871
 
        if (ipcperms (&sma->sem_perm, (cmd==SETVAL||cmd==SETALL)?S_IWUGO:S_IRUGO))
 
865
        if (ipcperms(ns, &sma->sem_perm,
 
866
                        (cmd == SETVAL || cmd == SETALL) ? S_IWUGO : S_IRUGO))
872
867
                goto out_unlock;
873
868
 
874
869
        err = security_sem_semctl(sma, cmd);
1053
1048
                        return -EFAULT;
1054
1049
        }
1055
1050
 
1056
 
        ipcp = ipcctl_pre_down(&sem_ids(ns), semid, cmd, &semid64.sem_perm, 0);
 
1051
        ipcp = ipcctl_pre_down(ns, &sem_ids(ns), semid, cmd,
 
1052
                               &semid64.sem_perm, 0);
1057
1053
        if (IS_ERR(ipcp))
1058
1054
                return PTR_ERR(ipcp);
1059
1055
 
1366
1362
         * semid identifiers are not unique - find_alloc_undo may have
1367
1363
         * allocated an undo structure, it was invalidated by an RMID
1368
1364
         * and now a new array with received the same id. Check and fail.
1369
 
         * This case can be detected checking un->semid. The existance of
 
1365
         * This case can be detected checking un->semid. The existence of
1370
1366
         * "un" itself is guaranteed by rcu.
1371
1367
         */
1372
1368
        error = -EIDRM;
1392
1388
                goto out_unlock_free;
1393
1389
 
1394
1390
        error = -EACCES;
1395
 
        if (ipcperms(&sma->sem_perm, alter ? S_IWUGO : S_IRUGO))
 
1391
        if (ipcperms(ns, &sma->sem_perm, alter ? S_IWUGO : S_IRUGO))
1396
1392
                goto out_unlock_free;
1397
1393
 
1398
1394
        error = security_sem_semop(sma, sops, nsops, alter);