aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/util.c
diff options
context:
space:
mode:
authorNadia Derbey <Nadia.Derbey@bull.net>2007-10-19 02:40:51 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:44 -0400
commit023a53557ea0e987b002e9a844242ef0b0aa1eb3 (patch)
tree7f3accdd7cb1d801607bf71e56b9b99e9c7ff7ca /ipc/util.c
parent637c36634029e4e7c81112796dafc32d56355b4a (diff)
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: Nadia Derbey <Nadia.Derbey@bull.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc/util.c')
-rw-r--r--ipc/util.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/ipc/util.c b/ipc/util.c
index e72865f677a7..9b0c4e7753af 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -678,7 +678,7 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
678 out = idr_find(&ids->ipcs_idr, lid); 678 out = idr_find(&ids->ipcs_idr, lid);
679 if (out == NULL) { 679 if (out == NULL) {
680 rcu_read_unlock(); 680 rcu_read_unlock();
681 return NULL; 681 return ERR_PTR(-EINVAL);
682 } 682 }
683 683
684 spin_lock(&out->lock); 684 spin_lock(&out->lock);
@@ -689,36 +689,17 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
689 if (out->deleted) { 689 if (out->deleted) {
690 spin_unlock(&out->lock); 690 spin_unlock(&out->lock);
691 rcu_read_unlock(); 691 rcu_read_unlock();
692 return NULL; 692 return ERR_PTR(-EINVAL);
693 } 693 }
694 694
695 return out; 695 return out;
696} 696}
697 697
698void ipc_lock_by_ptr(struct kern_ipc_perm *perm)
699{
700 rcu_read_lock();
701 spin_lock(&perm->lock);
702}
703
704void ipc_unlock(struct kern_ipc_perm* perm)
705{
706 spin_unlock(&perm->lock);
707 rcu_read_unlock();
708}
709
710int ipc_buildid(struct ipc_ids* ids, int id, int seq) 698int ipc_buildid(struct ipc_ids* ids, int id, int seq)
711{ 699{
712 return SEQ_MULTIPLIER*seq + id; 700 return SEQ_MULTIPLIER*seq + id;
713} 701}
714 702
715int ipc_checkid(struct ipc_ids* ids, struct kern_ipc_perm* ipcp, int uid)
716{
717 if(uid/SEQ_MULTIPLIER != ipcp->seq)
718 return 1;
719 return 0;
720}
721
722#ifdef __ARCH_WANT_IPC_PARSE_VERSION 703#ifdef __ARCH_WANT_IPC_PARSE_VERSION
723 704
724 705