mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
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().
[[email protected]: build fix]
[[email protected]: fix RCU locking]
Signed-off-by: Nadia Derbey <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
637c366340
commit
023a53557e
5 changed files with 152 additions and 136 deletions
23
ipc/util.c
23
ipc/util.c
|
|
@ -678,7 +678,7 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
|
|||
out = idr_find(&ids->ipcs_idr, lid);
|
||||
if (out == NULL) {
|
||||
rcu_read_unlock();
|
||||
return NULL;
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
spin_lock(&out->lock);
|
||||
|
|
@ -689,36 +689,17 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
|
|||
if (out->deleted) {
|
||||
spin_unlock(&out->lock);
|
||||
rcu_read_unlock();
|
||||
return NULL;
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return SEQ_MULTIPLIER*seq + id;
|
||||
}
|
||||
|
||||
int ipc_checkid(struct ipc_ids* ids, struct kern_ipc_perm* ipcp, int uid)
|
||||
{
|
||||
if(uid/SEQ_MULTIPLIER != ipcp->seq)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __ARCH_WANT_IPC_PARSE_VERSION
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue