Skip to content

Commit 4241c1a

Browse files
manfred-colorfutorvalds
authored andcommitted
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>
1 parent 39cfffd commit 4241c1a

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

ipc/msg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
386386
down_write(&msg_ids(ns).rwsem);
387387
rcu_read_lock();
388388

389-
ipcp = ipcctl_pre_down_nolock(ns, &msg_ids(ns), msqid, cmd,
389+
ipcp = ipcctl_obtain_check(ns, &msg_ids(ns), msqid, cmd,
390390
&msqid64->msg_perm, msqid64->msg_qbytes);
391391
if (IS_ERR(ipcp)) {
392392
err = PTR_ERR(ipcp);

ipc/sem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid,
15961596
down_write(&sem_ids(ns).rwsem);
15971597
rcu_read_lock();
15981598

1599-
ipcp = ipcctl_pre_down_nolock(ns, &sem_ids(ns), semid, cmd,
1599+
ipcp = ipcctl_obtain_check(ns, &sem_ids(ns), semid, cmd,
16001600
&semid64->sem_perm, 0);
16011601
if (IS_ERR(ipcp)) {
16021602
err = PTR_ERR(ipcp);

ipc/shm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd,
881881
down_write(&shm_ids(ns).rwsem);
882882
rcu_read_lock();
883883

884-
ipcp = ipcctl_pre_down_nolock(ns, &shm_ids(ns), shmid, cmd,
884+
ipcp = ipcctl_obtain_check(ns, &shm_ids(ns), shmid, cmd,
885885
&shmid64->shm_perm, 0);
886886
if (IS_ERR(ipcp)) {
887887
err = PTR_ERR(ipcp);

ipc/util.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out)
688688
}
689689

690690
/**
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
692692
* @ns: ipc namespace
693693
* @ids: the table of ids where to look for the ipc
694694
* @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)
698698
*
699699
* This function does some common audit and permissions check for some IPC_XXX
700700
* cmd and is called from semctl_down, shmctl_down and msgctl_down.
701-
* It must be called without any lock held and:
702701
*
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.
704704
* - performs some audit and permission check, depending on the given cmd
705705
* - returns a pointer to the ipc object or otherwise, the corresponding
706706
* error.
707707
*
708708
* Call holding the both the rwsem and the rcu read lock.
709709
*/
710-
struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns,
710+
struct kern_ipc_perm *ipcctl_obtain_check(struct ipc_namespace *ns,
711711
struct ipc_ids *ids, int id, int cmd,
712712
struct ipc64_perm *perm, int extra_perm)
713713
{

ipc/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id);
148148
void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out);
149149
void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out);
150150
int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out);
151-
struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns,
151+
struct kern_ipc_perm *ipcctl_obtain_check(struct ipc_namespace *ns,
152152
struct ipc_ids *ids, int id, int cmd,
153153
struct ipc64_perm *perm, int extra_perm);
154154

0 commit comments

Comments
 (0)