diff options
Diffstat (limited to 'ipc/util.c')
-rw-r--r-- | ipc/util.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/ipc/util.c b/ipc/util.c index 5432b8e34c9b..910db7748199 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
@@ -248,7 +248,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size) | |||
248 | * This routine is called by sys_msgget, sys_semget() and sys_shmget() | 248 | * This routine is called by sys_msgget, sys_semget() and sys_shmget() |
249 | * when the key is IPC_PRIVATE. | 249 | * when the key is IPC_PRIVATE. |
250 | */ | 250 | */ |
251 | int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids, | 251 | static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids, |
252 | struct ipc_ops *ops, struct ipc_params *params) | 252 | struct ipc_ops *ops, struct ipc_params *params) |
253 | { | 253 | { |
254 | int err; | 254 | int err; |
@@ -312,7 +312,7 @@ static int ipc_check_perms(struct kern_ipc_perm *ipcp, struct ipc_ops *ops, | |||
312 | * | 312 | * |
313 | * On success, the ipc id is returned. | 313 | * On success, the ipc id is returned. |
314 | */ | 314 | */ |
315 | int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids, | 315 | static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids, |
316 | struct ipc_ops *ops, struct ipc_params *params) | 316 | struct ipc_ops *ops, struct ipc_params *params) |
317 | { | 317 | { |
318 | struct kern_ipc_perm *ipcp; | 318 | struct kern_ipc_perm *ipcp; |
@@ -710,6 +710,57 @@ struct kern_ipc_perm *ipc_lock_down(struct ipc_ids *ids, int id) | |||
710 | return out; | 710 | return out; |
711 | } | 711 | } |
712 | 712 | ||
713 | struct kern_ipc_perm *ipc_lock_check_down(struct ipc_ids *ids, int id) | ||
714 | { | ||
715 | struct kern_ipc_perm *out; | ||
716 | |||
717 | out = ipc_lock_down(ids, id); | ||
718 | if (IS_ERR(out)) | ||
719 | return out; | ||
720 | |||
721 | if (ipc_checkid(out, id)) { | ||
722 | ipc_unlock(out); | ||
723 | return ERR_PTR(-EIDRM); | ||
724 | } | ||
725 | |||
726 | return out; | ||
727 | } | ||
728 | |||
729 | struct kern_ipc_perm *ipc_lock_check(struct ipc_ids *ids, int id) | ||
730 | { | ||
731 | struct kern_ipc_perm *out; | ||
732 | |||
733 | out = ipc_lock(ids, id); | ||
734 | if (IS_ERR(out)) | ||
735 | return out; | ||
736 | |||
737 | if (ipc_checkid(out, id)) { | ||
738 | ipc_unlock(out); | ||
739 | return ERR_PTR(-EIDRM); | ||
740 | } | ||
741 | |||
742 | return out; | ||
743 | } | ||
744 | |||
745 | /** | ||
746 | * ipcget - Common sys_*get() code | ||
747 | * @ns : namsepace | ||
748 | * @ids : IPC identifier set | ||
749 | * @ops : operations to be called on ipc object creation, permission checks | ||
750 | * and further checks | ||
751 | * @params : the parameters needed by the previous operations. | ||
752 | * | ||
753 | * Common routine called by sys_msgget(), sys_semget() and sys_shmget(). | ||
754 | */ | ||
755 | int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, | ||
756 | struct ipc_ops *ops, struct ipc_params *params) | ||
757 | { | ||
758 | if (params->key == IPC_PRIVATE) | ||
759 | return ipcget_new(ns, ids, ops, params); | ||
760 | else | ||
761 | return ipcget_public(ns, ids, ops, params); | ||
762 | } | ||
763 | |||
713 | #ifdef __ARCH_WANT_IPC_PARSE_VERSION | 764 | #ifdef __ARCH_WANT_IPC_PARSE_VERSION |
714 | 765 | ||
715 | 766 | ||