mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
ipc: introduce ipc_valid_object() helper to sort out IPC_RMID races
After the locking semantics for the SysV IPC API got improved, a couple of IPC_RMID race windows were opened because we ended up dropping the 'kern_ipc_perm.deleted' check performed way down in ipc_lock(). The spotted races got sorted out by re-introducing the old test within the racy critical sections. This patch introduces ipc_valid_object() to consolidate the way we cope with IPC_RMID races by using the same abstraction across the API implementation. Signed-off-by: Rafael Aquini <[email protected]> Acked-by: Rik van Riel <[email protected]> Acked-by: Greg Thelen <[email protected]> Reviewed-by: Davidlohr Bueso <[email protected]> Cc: Manfred Spraul <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
78f5009cc3
commit
0f3d2b0135
4 changed files with 41 additions and 19 deletions
13
ipc/util.h
13
ipc/util.h
|
|
@ -185,6 +185,19 @@ static inline void ipc_unlock(struct kern_ipc_perm *perm)
|
|||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
/*
|
||||
* ipc_valid_object() - helper to sort out IPC_RMID races for codepaths
|
||||
* where the respective ipc_ids.rwsem is not being held down.
|
||||
* Checks whether the ipc object is still around or if it's gone already, as
|
||||
* ipc_rmid() may have already freed the ID while the ipc lock was spinning.
|
||||
* Needs to be called with kern_ipc_perm.lock held -- exception made for one
|
||||
* checkpoint case at sys_semtimedop() as noted in code commentary.
|
||||
*/
|
||||
static inline bool ipc_valid_object(struct kern_ipc_perm *perm)
|
||||
{
|
||||
return perm->deleted == 0;
|
||||
}
|
||||
|
||||
struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id);
|
||||
int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids,
|
||||
struct ipc_ops *ops, struct ipc_params *params);
|
||||
|
|
|
|||
Loading…
Reference in a new issue