aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorManfred Spraul <manfred@colorfullife.com>2018-08-22 01:01:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-22 13:52:51 -0400
commit4241c1a304078569f544d51eeaf8bc270b6e377a (patch)
tree9468a64167df7d9919bfab0f3206baa937ab7235 /ipc
parent39cfffd774a2e8818250360a3e028b5eac9d5392 (diff)
ipc: rename ipcctl_pre_down_nolock()
Both the comment and the name of ipcctl_pre_down_nolock() are misleading: The function must be called while holdling the rw semaphore. Therefore the patch renames the function to ipcctl_obtain_check(): This name matches the other names used in util.c: - "obtain" function look up a pointer in the idr, without acquiring the object lock. - The caller is responsible for locking. - _check means that the sequence number is checked. Link: http://lkml.kernel.org/r/20180712185241.4017-5-manfred@colorfullife.com Signed-off-by: Manfred Spraul <manfred@colorfullife.com> Reviewed-by: Davidlohr Bueso <dbueso@suse.de> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Kees Cook <keescook@chromium.org> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Cc: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/msg.c2
-rw-r--r--ipc/sem.c2
-rw-r--r--ipc/shm.c2
-rw-r--r--ipc/util.c8
-rw-r--r--ipc/util.h2
5 files changed, 8 insertions, 8 deletions
diff --git a/ipc/msg.c b/ipc/msg.c
index 3132aa27ff88..b9b47d6cd7ee 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -386,7 +386,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
386 down_write(&msg_ids(ns).rwsem); 386 down_write(&msg_ids(ns).rwsem);
387 rcu_read_lock(); 387 rcu_read_lock();
388 388
389 ipcp = ipcctl_pre_down_nolock(ns, &msg_ids(ns), msqid, cmd, 389 ipcp = ipcctl_obtain_check(ns, &msg_ids(ns), msqid, cmd,
390 &msqid64->msg_perm, msqid64->msg_qbytes); 390 &msqid64->msg_perm, msqid64->msg_qbytes);
391 if (IS_ERR(ipcp)) { 391 if (IS_ERR(ipcp)) {
392 err = PTR_ERR(ipcp); 392 err = PTR_ERR(ipcp);
diff --git a/ipc/sem.c b/ipc/sem.c
index 8e72037b894a..cf2ba4509f0d 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1596,7 +1596,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid,
1596 down_write(&sem_ids(ns).rwsem); 1596 down_write(&sem_ids(ns).rwsem);
1597 rcu_read_lock(); 1597 rcu_read_lock();
1598 1598
1599 ipcp = ipcctl_pre_down_nolock(ns, &sem_ids(ns), semid, cmd, 1599 ipcp = ipcctl_obtain_check(ns, &sem_ids(ns), semid, cmd,
1600 &semid64->sem_perm, 0); 1600 &semid64->sem_perm, 0);
1601 if (IS_ERR(ipcp)) { 1601 if (IS_ERR(ipcp)) {
1602 err = PTR_ERR(ipcp); 1602 err = PTR_ERR(ipcp);
diff --git a/ipc/shm.c b/ipc/shm.c
index 6e7bd9830549..a413ddf74dac 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -881,7 +881,7 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd,
881 down_write(&shm_ids(ns).rwsem); 881 down_write(&shm_ids(ns).rwsem);
882 rcu_read_lock(); 882 rcu_read_lock();
883 883
884 ipcp = ipcctl_pre_down_nolock(ns, &shm_ids(ns), shmid, cmd, 884 ipcp = ipcctl_obtain_check(ns, &shm_ids(ns), shmid, cmd,
885 &shmid64->shm_perm, 0); 885 &shmid64->shm_perm, 0);
886 if (IS_ERR(ipcp)) { 886 if (IS_ERR(ipcp)) {
887 err = PTR_ERR(ipcp); 887 err = PTR_ERR(ipcp);
diff --git a/ipc/util.c b/ipc/util.c
index 465bbd21d234..1d88dffd75e7 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -688,7 +688,7 @@ int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out)
688} 688}
689 689
690/** 690/**
691 * ipcctl_pre_down_nolock - retrieve an ipc and check permissions for some IPC_XXX cmd 691 * ipcctl_obtain_check - retrieve an ipc object and check permissions
692 * @ns: ipc namespace 692 * @ns: ipc namespace
693 * @ids: the table of ids where to look for the ipc 693 * @ids: the table of ids where to look for the ipc
694 * @id: the id of the ipc to retrieve 694 * @id: the id of the ipc to retrieve
@@ -698,16 +698,16 @@ int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out)
698 * 698 *
699 * This function does some common audit and permissions check for some IPC_XXX 699 * This function does some common audit and permissions check for some IPC_XXX
700 * cmd and is called from semctl_down, shmctl_down and msgctl_down. 700 * cmd and is called from semctl_down, shmctl_down and msgctl_down.
701 * It must be called without any lock held and:
702 * 701 *
703 * - retrieves the ipc with the given id in the given table. 702 * It:
703 * - retrieves the ipc object with the given id in the given table.
704 * - performs some audit and permission check, depending on the given cmd 704 * - performs some audit and permission check, depending on the given cmd
705 * - returns a pointer to the ipc object or otherwise, the corresponding 705 * - returns a pointer to the ipc object or otherwise, the corresponding
706 * error. 706 * error.
707 * 707 *
708 * Call holding the both the rwsem and the rcu read lock. 708 * Call holding the both the rwsem and the rcu read lock.
709 */ 709 */
710struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns, 710struct kern_ipc_perm *ipcctl_obtain_check(struct ipc_namespace *ns,
711 struct ipc_ids *ids, int id, int cmd, 711 struct ipc_ids *ids, int id, int cmd,
712 struct ipc64_perm *perm, int extra_perm) 712 struct ipc64_perm *perm, int extra_perm)
713{ 713{
diff --git a/ipc/util.h b/ipc/util.h
index 0aba3230d007..fcf81425ae98 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -148,7 +148,7 @@ struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id);
148void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out); 148void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out);
149void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out); 149void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out);
150int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out); 150int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out);
151struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns, 151struct kern_ipc_perm *ipcctl_obtain_check(struct ipc_namespace *ns,
152 struct ipc_ids *ids, int id, int cmd, 152 struct ipc_ids *ids, int id, int cmd,
153 struct ipc64_perm *perm, int extra_perm); 153 struct ipc64_perm *perm, int extra_perm);
154 154