mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
ipc: drop ipc_lock()
ipc/util.c contains multiple functions to get the ipc object pointer given an id number. There are two sets of function: One set verifies the sequence counter part of the id number, other functions do not check the sequence counter. The standard for function names in ipc/util.c is - ..._check() functions verify the sequence counter - ..._idr() functions do not verify the sequence counter ipc_lock() is an exception: It does not verify the sequence counter value, but this is not obvious from the function name. Furthermore, shm.c is the only user of this helper. Thus, we can simply move the logic into shm_lock() and get rid of the function altogether. [[email protected]: most of changelog] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Davidlohr Bueso <[email protected]> Signed-off-by: Manfred Spraul <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Herbert Xu <[email protected]> Cc: Kees Cook <[email protected]> Cc: Michael Kerrisk <[email protected]> Cc: Michal Hocko <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
2e5ceb452c
commit
82061c57ce
3 changed files with 23 additions and 43 deletions
36
ipc/util.c
36
ipc/util.c
|
|
@ -588,42 +588,6 @@ struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id)
|
|||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* ipc_lock - lock an ipc structure without rwsem held
|
||||
* @ids: ipc identifier set
|
||||
* @id: ipc id to look for
|
||||
*
|
||||
* Look for an id in the ipc ids idr and lock the associated ipc object.
|
||||
*
|
||||
* The ipc object is locked on successful exit.
|
||||
*/
|
||||
struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
|
||||
{
|
||||
struct kern_ipc_perm *out;
|
||||
|
||||
rcu_read_lock();
|
||||
out = ipc_obtain_object_idr(ids, id);
|
||||
if (IS_ERR(out))
|
||||
goto err;
|
||||
|
||||
spin_lock(&out->lock);
|
||||
|
||||
/*
|
||||
* ipc_rmid() may have already freed the ID while ipc_lock()
|
||||
* was spinning: here verify that the structure is still valid.
|
||||
* Upon races with RMID, return -EIDRM, thus indicating that
|
||||
* the ID points to a removed identifier.
|
||||
*/
|
||||
if (ipc_valid_object(out))
|
||||
return out;
|
||||
|
||||
spin_unlock(&out->lock);
|
||||
out = ERR_PTR(-EIDRM);
|
||||
err:
|
||||
rcu_read_unlock();
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* ipc_obtain_object_check
|
||||
* @ids: ipc identifier set
|
||||
|
|
|
|||
Loading…
Reference in a new issue