Commit 023a5355 authored by Nadia Derbey's avatar Nadia Derbey Committed by Linus Torvalds
Browse files

ipc: integrate ipc_checkid() into ipc_lock()



This patch introduces a new ipc_lock_check() routine interface:
   . each time ipc_checkid() is called, this is done after calling ipc_lock().
     ipc_checkid() is now called from inside ipc_lock_check().

[akpm@linux-foundation.org: build fix]
[akpm@linux-foundation.org: fix RCU locking]
Signed-off-by: default avatarNadia Derbey <Nadia.Derbey@bull.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 637c3663
...@@ -73,10 +73,7 @@ static struct ipc_ids init_msg_ids; ...@@ -73,10 +73,7 @@ static struct ipc_ids init_msg_ids;
#define msg_ids(ns) (*((ns)->ids[IPC_MSG_IDS])) #define msg_ids(ns) (*((ns)->ids[IPC_MSG_IDS]))
#define msg_lock(ns, id) ((struct msg_queue*)ipc_lock(&msg_ids(ns), id))
#define msg_unlock(msq) ipc_unlock(&(msq)->q_perm) #define msg_unlock(msq) ipc_unlock(&(msq)->q_perm)
#define msg_checkid(ns, msq, msgid) \
ipc_checkid(&msg_ids(ns), &msq->q_perm, msgid)
#define msg_buildid(ns, id, seq) \ #define msg_buildid(ns, id, seq) \
ipc_buildid(&msg_ids(ns), id, seq) ipc_buildid(&msg_ids(ns), id, seq)
...@@ -139,6 +136,17 @@ void __init msg_init(void) ...@@ -139,6 +136,17 @@ void __init msg_init(void)
IPC_MSG_IDS, sysvipc_msg_proc_show); IPC_MSG_IDS, sysvipc_msg_proc_show);
} }
static inline struct msg_queue *msg_lock(struct ipc_namespace *ns, int id)
{
return (struct msg_queue *) ipc_lock(&msg_ids(ns), id);
}
static inline struct msg_queue *msg_lock_check(struct ipc_namespace *ns,
int id)
{
return (struct msg_queue *) ipc_lock_check(&msg_ids(ns), id);
}
static inline void msg_rmid(struct ipc_namespace *ns, struct msg_queue *s) static inline void msg_rmid(struct ipc_namespace *ns, struct msg_queue *s)
{ {
ipc_rmid(&msg_ids(ns), &s->q_perm); ipc_rmid(&msg_ids(ns), &s->q_perm);
...@@ -445,18 +453,15 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf) ...@@ -445,18 +453,15 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
if (!buf) if (!buf)
return -EFAULT; return -EFAULT;
memset(&tbuf, 0, sizeof(tbuf));
msq = msg_lock(ns, msqid);
if (msq == NULL)
return -EINVAL;
if (cmd == MSG_STAT) { if (cmd == MSG_STAT) {
msq = msg_lock(ns, msqid);
if (IS_ERR(msq))
return PTR_ERR(msq);
success_return = msq->q_perm.id; success_return = msq->q_perm.id;
} else { } else {
err = -EIDRM; msq = msg_lock_check(ns, msqid);
if (msg_checkid(ns, msq, msqid)) if (IS_ERR(msq))
goto out_unlock; return PTR_ERR(msq);
success_return = 0; success_return = 0;
} }
err = -EACCES; err = -EACCES;
...@@ -467,6 +472,8 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf) ...@@ -467,6 +472,8 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
if (err) if (err)
goto out_unlock; goto out_unlock;
memset(&tbuf, 0, sizeof(tbuf));
kernel_to_ipc64_perm(&msq->q_perm, &tbuf.msg_perm); kernel_to_ipc64_perm(&msq->q_perm, &tbuf.msg_perm);
tbuf.msg_stime = msq->q_stime; tbuf.msg_stime = msq->q_stime;
tbuf.msg_rtime = msq->q_rtime; tbuf.msg_rtime = msq->q_rtime;
...@@ -494,14 +501,12 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf) ...@@ -494,14 +501,12 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
} }
mutex_lock(&msg_ids(ns).mutex); mutex_lock(&msg_ids(ns).mutex);
msq = msg_lock(ns, msqid); msq = msg_lock_check(ns, msqid);
err = -EINVAL; if (IS_ERR(msq)) {
if (msq == NULL) err = PTR_ERR(msq);
goto out_up; goto out_up;
}
err = -EIDRM;
if (msg_checkid(ns, msq, msqid))
goto out_unlock_up;
ipcp = &msq->q_perm; ipcp = &msq->q_perm;
err = audit_ipc_obj(ipcp); err = audit_ipc_obj(ipcp);
...@@ -644,14 +649,11 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext, ...@@ -644,14 +649,11 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext,
msg->m_type = mtype; msg->m_type = mtype;
msg->m_ts = msgsz; msg->m_ts = msgsz;
msq = msg_lock(ns, msqid); msq = msg_lock_check(ns, msqid);
err = -EINVAL; if (IS_ERR(msq)) {
if (msq == NULL) err = PTR_ERR(msq);
goto out_free; goto out_free;
}
err= -EIDRM;
if (msg_checkid(ns, msq, msqid))
goto out_unlock_free;
for (;;) { for (;;) {
struct msg_sender s; struct msg_sender s;
...@@ -758,13 +760,9 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext, ...@@ -758,13 +760,9 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
mode = convert_mode(&msgtyp, msgflg); mode = convert_mode(&msgtyp, msgflg);
ns = current->nsproxy->ipc_ns; ns = current->nsproxy->ipc_ns;
msq = msg_lock(ns, msqid); msq = msg_lock_check(ns, msqid);
if (msq == NULL) if (IS_ERR(msq))
return -EINVAL; return PTR_ERR(msq);
msg = ERR_PTR(-EIDRM);
if (msg_checkid(ns, msq, msqid))
goto out_unlock;
for (;;) { for (;;) {
struct msg_receiver msr_d; struct msg_receiver msr_d;
......
...@@ -88,7 +88,6 @@ ...@@ -88,7 +88,6 @@
#define sem_ids(ns) (*((ns)->ids[IPC_SEM_IDS])) #define sem_ids(ns) (*((ns)->ids[IPC_SEM_IDS]))
#define sem_lock(ns, id) ((struct sem_array*)ipc_lock(&sem_ids(ns), id))
#define sem_unlock(sma) ipc_unlock(&(sma)->sem_perm) #define sem_unlock(sma) ipc_unlock(&(sma)->sem_perm)
#define sem_checkid(ns, sma, semid) \ #define sem_checkid(ns, sma, semid) \
ipc_checkid(&sem_ids(ns),&sma->sem_perm,semid) ipc_checkid(&sem_ids(ns),&sma->sem_perm,semid)
...@@ -175,6 +174,17 @@ void __init sem_init (void) ...@@ -175,6 +174,17 @@ void __init sem_init (void)
IPC_SEM_IDS, sysvipc_sem_proc_show); IPC_SEM_IDS, sysvipc_sem_proc_show);
} }
static inline struct sem_array *sem_lock(struct ipc_namespace *ns, int id)
{
return (struct sem_array *) ipc_lock(&sem_ids(ns), id);
}
static inline struct sem_array *sem_lock_check(struct ipc_namespace *ns,
int id)
{
return (struct sem_array *) ipc_lock_check(&sem_ids(ns), id);
}
static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s) static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s)
{ {
ipc_rmid(&sem_ids(ns), &s->sem_perm); ipc_rmid(&sem_ids(ns), &s->sem_perm);
...@@ -599,11 +609,9 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid, int semnum, ...@@ -599,11 +609,9 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid, int semnum,
struct semid64_ds tbuf; struct semid64_ds tbuf;
int id; int id;
memset(&tbuf,0,sizeof(tbuf));
sma = sem_lock(ns, semid); sma = sem_lock(ns, semid);
if(sma == NULL) if (IS_ERR(sma))
return -EINVAL; return PTR_ERR(sma);
err = -EACCES; err = -EACCES;
if (ipcperms (&sma->sem_perm, S_IRUGO)) if (ipcperms (&sma->sem_perm, S_IRUGO))
...@@ -615,6 +623,8 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid, int semnum, ...@@ -615,6 +623,8 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid, int semnum,
id = sma->sem_perm.id; id = sma->sem_perm.id;
memset(&tbuf, 0, sizeof(tbuf));
kernel_to_ipc64_perm(&sma->sem_perm, &tbuf.sem_perm); kernel_to_ipc64_perm(&sma->sem_perm, &tbuf.sem_perm);
tbuf.sem_otime = sma->sem_otime; tbuf.sem_otime = sma->sem_otime;
tbuf.sem_ctime = sma->sem_ctime; tbuf.sem_ctime = sma->sem_ctime;
...@@ -643,16 +653,12 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, ...@@ -643,16 +653,12 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
ushort* sem_io = fast_sem_io; ushort* sem_io = fast_sem_io;
int nsems; int nsems;
sma = sem_lock(ns, semid); sma = sem_lock_check(ns, semid);
if(sma==NULL) if (IS_ERR(sma))
return -EINVAL; return PTR_ERR(sma);
nsems = sma->sem_nsems; nsems = sma->sem_nsems;
err=-EIDRM;
if (sem_checkid(ns,sma,semid))
goto out_unlock;
err = -EACCES; err = -EACCES;
if (ipcperms (&sma->sem_perm, (cmd==SETVAL||cmd==SETALL)?S_IWUGO:S_IRUGO)) if (ipcperms (&sma->sem_perm, (cmd==SETVAL||cmd==SETALL)?S_IWUGO:S_IRUGO))
goto out_unlock; goto out_unlock;
...@@ -864,14 +870,10 @@ static int semctl_down(struct ipc_namespace *ns, int semid, int semnum, ...@@ -864,14 +870,10 @@ static int semctl_down(struct ipc_namespace *ns, int semid, int semnum,
if(copy_semid_from_user (&setbuf, arg.buf, version)) if(copy_semid_from_user (&setbuf, arg.buf, version))
return -EFAULT; return -EFAULT;
} }
sma = sem_lock(ns, semid); sma = sem_lock_check(ns, semid);
if(sma==NULL) if (IS_ERR(sma))
return -EINVAL; return PTR_ERR(sma);
if (sem_checkid(ns,sma,semid)) {
err=-EIDRM;
goto out_unlock;
}
ipcp = &sma->sem_perm; ipcp = &sma->sem_perm;
err = audit_ipc_obj(ipcp); err = audit_ipc_obj(ipcp);
...@@ -1055,15 +1057,10 @@ static struct sem_undo *find_undo(struct ipc_namespace *ns, int semid) ...@@ -1055,15 +1057,10 @@ static struct sem_undo *find_undo(struct ipc_namespace *ns, int semid)
goto out; goto out;
/* no undo structure around - allocate one. */ /* no undo structure around - allocate one. */
sma = sem_lock(ns, semid); sma = sem_lock_check(ns, semid);
un = ERR_PTR(-EINVAL); if (IS_ERR(sma))
if(sma==NULL) return ERR_PTR(PTR_ERR(sma));
goto out;
un = ERR_PTR(-EIDRM);
if (sem_checkid(ns,sma,semid)) {
sem_unlock(sma);
goto out;
}
nsems = sma->sem_nsems; nsems = sma->sem_nsems;
ipc_rcu_getref(sma); ipc_rcu_getref(sma);
sem_unlock(sma); sem_unlock(sma);
...@@ -1169,15 +1166,14 @@ retry_undos: ...@@ -1169,15 +1166,14 @@ retry_undos:
} else } else
un = NULL; un = NULL;
sma = sem_lock(ns, semid); sma = sem_lock_check(ns, semid);
error=-EINVAL; if (IS_ERR(sma)) {
if(sma==NULL) error = PTR_ERR(sma);
goto out_free; goto out_free;
error = -EIDRM; }
if (sem_checkid(ns,sma,semid))
goto out_unlock_free;
/* /*
* semid identifies are not unique - find_undo may have * semid identifiers are not unique - find_undo may have
* allocated an undo structure, it was invalidated by an RMID * allocated an undo structure, it was invalidated by an RMID
* and now a new array with received the same id. Check and retry. * and now a new array with received the same id. Check and retry.
*/ */
...@@ -1243,7 +1239,7 @@ retry_undos: ...@@ -1243,7 +1239,7 @@ retry_undos:
} }
sma = sem_lock(ns, semid); sma = sem_lock(ns, semid);
if(sma==NULL) { if (IS_ERR(sma)) {
BUG_ON(queue.prev != NULL); BUG_ON(queue.prev != NULL);
error = -EIDRM; error = -EIDRM;
goto out_free; goto out_free;
...@@ -1343,7 +1339,7 @@ void exit_sem(struct task_struct *tsk) ...@@ -1343,7 +1339,7 @@ void exit_sem(struct task_struct *tsk)
if(semid == -1) if(semid == -1)
continue; continue;
sma = sem_lock(ns, semid); sma = sem_lock(ns, semid);
if (sma == NULL) if (IS_ERR(sma))
continue; continue;
if (u->semid == -1) if (u->semid == -1)
......
...@@ -59,8 +59,6 @@ static struct ipc_ids init_shm_ids; ...@@ -59,8 +59,6 @@ static struct ipc_ids init_shm_ids;
#define shm_ids(ns) (*((ns)->ids[IPC_SHM_IDS])) #define shm_ids(ns) (*((ns)->ids[IPC_SHM_IDS]))
#define shm_lock(ns, id) \
((struct shmid_kernel*)ipc_lock(&shm_ids(ns),id))
#define shm_unlock(shp) \ #define shm_unlock(shp) \
ipc_unlock(&(shp)->shm_perm) ipc_unlock(&(shp)->shm_perm)
#define shm_buildid(ns, id, seq) \ #define shm_buildid(ns, id, seq) \
...@@ -139,12 +137,15 @@ void __init shm_init (void) ...@@ -139,12 +137,15 @@ void __init shm_init (void)
IPC_SHM_IDS, sysvipc_shm_proc_show); IPC_SHM_IDS, sysvipc_shm_proc_show);
} }
static inline int shm_checkid(struct ipc_namespace *ns, static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id)
struct shmid_kernel *s, int id)
{ {
if (ipc_checkid(&shm_ids(ns), &s->shm_perm, id)) return (struct shmid_kernel *) ipc_lock(&shm_ids(ns), id);
return -EIDRM; }
return 0;
static inline struct shmid_kernel *shm_lock_check(struct ipc_namespace *ns,
int id)
{
return (struct shmid_kernel *) ipc_lock_check(&shm_ids(ns), id);
} }
static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s) static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s)
...@@ -167,7 +168,7 @@ static void shm_open(struct vm_area_struct *vma) ...@@ -167,7 +168,7 @@ static void shm_open(struct vm_area_struct *vma)
struct shmid_kernel *shp; struct shmid_kernel *shp;
shp = shm_lock(sfd->ns, sfd->id); shp = shm_lock(sfd->ns, sfd->id);
BUG_ON(!shp); BUG_ON(IS_ERR(shp));
shp->shm_atim = get_seconds(); shp->shm_atim = get_seconds();
shp->shm_lprid = task_tgid_vnr(current); shp->shm_lprid = task_tgid_vnr(current);
shp->shm_nattch++; shp->shm_nattch++;
...@@ -213,7 +214,7 @@ static void shm_close(struct vm_area_struct *vma) ...@@ -213,7 +214,7 @@ static void shm_close(struct vm_area_struct *vma)
mutex_lock(&shm_ids(ns).mutex); mutex_lock(&shm_ids(ns).mutex);
/* remove from the list of attaches of the shm segment */ /* remove from the list of attaches of the shm segment */
shp = shm_lock(ns, sfd->id); shp = shm_lock(ns, sfd->id);
BUG_ON(!shp); BUG_ON(IS_ERR(shp));
shp->shm_lprid = task_tgid_vnr(current); shp->shm_lprid = task_tgid_vnr(current);
shp->shm_dtim = get_seconds(); shp->shm_dtim = get_seconds();
shp->shm_nattch--; shp->shm_nattch--;
...@@ -662,17 +663,25 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -662,17 +663,25 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
{ {
struct shmid64_ds tbuf; struct shmid64_ds tbuf;
int result; int result;
memset(&tbuf, 0, sizeof(tbuf));
if (!buf) {
err = -EFAULT;
goto out;
}
if (cmd == SHM_STAT) {
shp = shm_lock(ns, shmid); shp = shm_lock(ns, shmid);
if(shp==NULL) { if (IS_ERR(shp)) {
err = -EINVAL; err = PTR_ERR(shp);
goto out; goto out;
} else if (cmd == SHM_STAT) { }
result = shp->shm_perm.id; result = shp->shm_perm.id;
} else { } else {
err = shm_checkid(ns, shp,shmid); shp = shm_lock_check(ns, shmid);
if(err) if (IS_ERR(shp)) {
goto out_unlock; err = PTR_ERR(shp);
goto out;
}
result = 0; result = 0;
} }
err=-EACCES; err=-EACCES;
...@@ -681,6 +690,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -681,6 +690,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
err = security_shm_shmctl(shp, cmd); err = security_shm_shmctl(shp, cmd);
if (err) if (err)
goto out_unlock; goto out_unlock;
memset(&tbuf, 0, sizeof(tbuf));
kernel_to_ipc64_perm(&shp->shm_perm, &tbuf.shm_perm); kernel_to_ipc64_perm(&shp->shm_perm, &tbuf.shm_perm);
tbuf.shm_segsz = shp->shm_segsz; tbuf.shm_segsz = shp->shm_segsz;
tbuf.shm_atime = shp->shm_atim; tbuf.shm_atime = shp->shm_atim;
...@@ -699,14 +709,11 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -699,14 +709,11 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
case SHM_LOCK: case SHM_LOCK:
case SHM_UNLOCK: case SHM_UNLOCK:
{ {
shp = shm_lock(ns, shmid); shp = shm_lock_check(ns, shmid);
if(shp==NULL) { if (IS_ERR(shp)) {
err = -EINVAL; err = PTR_ERR(shp);
goto out; goto out;
} }
err = shm_checkid(ns, shp,shmid);
if(err)
goto out_unlock;
err = audit_ipc_obj(&(shp->shm_perm)); err = audit_ipc_obj(&(shp->shm_perm));
if (err) if (err)
...@@ -756,13 +763,11 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -756,13 +763,11 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
* the name away when the usage hits zero. * the name away when the usage hits zero.
*/ */
mutex_lock(&shm_ids(ns).mutex); mutex_lock(&shm_ids(ns).mutex);
shp = shm_lock(ns, shmid); shp = shm_lock_check(ns, shmid);
err = -EINVAL; if (IS_ERR(shp)) {
if (shp == NULL) err = PTR_ERR(shp);
goto out_up; goto out_up;
err = shm_checkid(ns, shp, shmid); }
if(err)
goto out_unlock_up;
err = audit_ipc_obj(&(shp->shm_perm)); err = audit_ipc_obj(&(shp->shm_perm));
if (err) if (err)
...@@ -786,18 +791,21 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -786,18 +791,21 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
case IPC_SET: case IPC_SET:
{ {
if (!buf) {
err = -EFAULT;
goto out;
}
if (copy_shmid_from_user (&setbuf, buf, version)) { if (copy_shmid_from_user (&setbuf, buf, version)) {
err = -EFAULT; err = -EFAULT;
goto out; goto out;
} }
mutex_lock(&shm_ids(ns).mutex); mutex_lock(&shm_ids(ns).mutex);
shp = shm_lock(ns, shmid); shp = shm_lock_check(ns, shmid);
err=-EINVAL; if (IS_ERR(shp)) {
if(shp==NULL) err = PTR_ERR(shp);
goto out_up; goto out_up;
err = shm_checkid(ns, shp,shmid); }
if(err)
goto out_unlock_up;
err = audit_ipc_obj(&(shp->shm_perm)); err = audit_ipc_obj(&(shp->shm_perm));
if (err) if (err)
goto out_unlock_up; goto out_unlock_up;
...@@ -903,13 +911,11 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr) ...@@ -903,13 +911,11 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
* additional creator id... * additional creator id...
*/ */
ns = current->nsproxy->ipc_ns; ns = current->nsproxy->ipc_ns;
shp = shm_lock(ns, shmid); shp = shm_lock_check(ns, shmid);
if(shp == NULL) if (IS_ERR(shp)) {
err = PTR_ERR(shp);
goto out; goto out;
}
err = shm_checkid(ns, shp,shmid);
if (err)
goto out_unlock;
err = -EACCES; err = -EACCES;
if (ipcperms(&shp->shm_perm, acc_mode)) if (ipcperms(&shp->shm_perm, acc_mode))
...@@ -970,7 +976,7 @@ invalid: ...@@ -970,7 +976,7 @@ invalid:
out_nattch: out_nattch:
mutex_lock(&shm_ids(ns).mutex); mutex_lock(&shm_ids(ns).mutex);
shp = shm_lock(ns, shmid); shp = shm_lock(ns, shmid);
BUG_ON(!shp); BUG_ON(IS_ERR(shp));
shp->shm_nattch--; shp->shm_nattch--;
if(shp->shm_nattch == 0 && if(shp->shm_nattch == 0 &&
shp->shm_perm.mode & SHM_DEST) shp->shm_perm.mode & SHM_DEST)
......
...@@ -678,7 +678,7 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id) ...@@ -678,7 +678,7 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
out = idr_find(&ids->ipcs_idr, lid); out = idr_find(&ids->ipcs_idr, lid);
if (out == NULL) { if (out == NULL) {
rcu_read_unlock(); rcu_read_unlock();
return NULL; return ERR_PTR(-EINVAL);
} }
spin_lock(&out->lock); spin_lock(&out->lock);
...@@ -689,36 +689,17 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id) ...@@ -689,36 +689,17 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
if (out->deleted) { if (out->deleted) {
spin_unlock(&out->lock); spin_unlock(&out->lock);
rcu_read_unlock(); rcu_read_unlock();
return NULL; return ERR_PTR(-EINVAL);
} }
return out; return out;
} }
void ipc_lock_by_ptr(struct kern_ipc_perm *perm)
{
rcu_read_lock();
spin_lock(&perm->lock);
}
void ipc_unlock(struct kern_ipc_perm* perm)
{
spin_unlock(&perm->lock);
rcu_read_unlock();
}
int ipc_buildid(struct ipc_ids* ids, int id, int seq) int ipc_buildid(struct ipc_ids* ids, int id, int seq)
{ {