Commit 27c331a174614208d0b539019583990967ad9479
Committed by
Linus Torvalds
1 parent
eae04d25a7
Exists in
smarc_imx_lf-5.15.y
and in
15 other branches
ipc/util.c: further variable name cleanups
The varable names got a mess, thus standardize them again:
id: user space id. Called semid, shmid, msgid if the type is known.
Most functions use "id" already.
idx: "index" for the idr lookup
Right now, some functions use lid, ipc_addid() already uses idx as
the variable name.
seq: sequence number, to avoid quick collisions of the user space id
key: user space key, used for the rhash tree
Link: http://lkml.kernel.org/r/20180712185241.4017-12-manfred@colorfullife.com
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Davidlohr Bueso <dbueso@suse.de>
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>
Showing 6 changed files with 27 additions and 27 deletions Side-by-side Diff
include/linux/ipc_namespace.h
ipc/msg.c
| ... | ... | @@ -456,7 +456,7 @@ |
| 456 | 456 | int cmd, struct msginfo *msginfo) |
| 457 | 457 | { |
| 458 | 458 | int err; |
| 459 | - int max_id; | |
| 459 | + int max_idx; | |
| 460 | 460 | |
| 461 | 461 | /* |
| 462 | 462 | * We must not return kernel stack data. |
| 463 | 463 | |
| ... | ... | @@ -483,9 +483,9 @@ |
| 483 | 483 | msginfo->msgpool = MSGPOOL; |
| 484 | 484 | msginfo->msgtql = MSGTQL; |
| 485 | 485 | } |
| 486 | - max_id = ipc_get_maxid(&msg_ids(ns)); | |
| 486 | + max_idx = ipc_get_maxidx(&msg_ids(ns)); | |
| 487 | 487 | up_read(&msg_ids(ns).rwsem); |
| 488 | - return (max_id < 0) ? 0 : max_id; | |
| 488 | + return (max_idx < 0) ? 0 : max_idx; | |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | static int msgctl_stat(struct ipc_namespace *ns, int msqid, |
ipc/sem.c
| ... | ... | @@ -1294,7 +1294,7 @@ |
| 1294 | 1294 | int cmd, void __user *p) |
| 1295 | 1295 | { |
| 1296 | 1296 | struct seminfo seminfo; |
| 1297 | - int max_id; | |
| 1297 | + int max_idx; | |
| 1298 | 1298 | int err; |
| 1299 | 1299 | |
| 1300 | 1300 | err = security_sem_semctl(NULL, cmd); |
| 1301 | 1301 | |
| ... | ... | @@ -1318,11 +1318,11 @@ |
| 1318 | 1318 | seminfo.semusz = SEMUSZ; |
| 1319 | 1319 | seminfo.semaem = SEMAEM; |
| 1320 | 1320 | } |
| 1321 | - max_id = ipc_get_maxid(&sem_ids(ns)); | |
| 1321 | + max_idx = ipc_get_maxidx(&sem_ids(ns)); | |
| 1322 | 1322 | up_read(&sem_ids(ns).rwsem); |
| 1323 | 1323 | if (copy_to_user(p, &seminfo, sizeof(struct seminfo))) |
| 1324 | 1324 | return -EFAULT; |
| 1325 | - return (max_id < 0) ? 0 : max_id; | |
| 1325 | + return (max_idx < 0) ? 0 : max_idx; | |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | 1328 | static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum, |
ipc/shm.c
| ... | ... | @@ -948,7 +948,7 @@ |
| 948 | 948 | shminfo->shmall = ns->shm_ctlall; |
| 949 | 949 | shminfo->shmmin = SHMMIN; |
| 950 | 950 | down_read(&shm_ids(ns).rwsem); |
| 951 | - err = ipc_get_maxid(&shm_ids(ns)); | |
| 951 | + err = ipc_get_maxidx(&shm_ids(ns)); | |
| 952 | 952 | up_read(&shm_ids(ns).rwsem); |
| 953 | 953 | if (err < 0) |
| 954 | 954 | err = 0; |
| ... | ... | @@ -968,7 +968,7 @@ |
| 968 | 968 | shm_info->shm_tot = ns->shm_tot; |
| 969 | 969 | shm_info->swap_attempts = 0; |
| 970 | 970 | shm_info->swap_successes = 0; |
| 971 | - err = ipc_get_maxid(&shm_ids(ns)); | |
| 971 | + err = ipc_get_maxidx(&shm_ids(ns)); | |
| 972 | 972 | up_read(&shm_ids(ns).rwsem); |
| 973 | 973 | if (err < 0) |
| 974 | 974 | err = 0; |
ipc/util.c
| ... | ... | @@ -119,7 +119,7 @@ |
| 119 | 119 | init_rwsem(&ids->rwsem); |
| 120 | 120 | rhashtable_init(&ids->key_ht, &ipc_kht_params); |
| 121 | 121 | idr_init(&ids->ipcs_idr); |
| 122 | - ids->max_id = -1; | |
| 122 | + ids->max_idx = -1; | |
| 123 | 123 | #ifdef CONFIG_CHECKPOINT_RESTORE |
| 124 | 124 | ids->next_id = -1; |
| 125 | 125 | #endif |
| ... | ... | @@ -237,7 +237,7 @@ |
| 237 | 237 | * @limit: limit for the number of used ids |
| 238 | 238 | * |
| 239 | 239 | * Add an entry 'new' to the ipc ids idr. The permissions object is |
| 240 | - * initialised and the first free entry is set up and the id assigned | |
| 240 | + * initialised and the first free entry is set up and the index assigned | |
| 241 | 241 | * is returned. The 'new' entry is returned in a locked state on success. |
| 242 | 242 | * |
| 243 | 243 | * On failure the entry is not locked and a negative err-code is returned. |
| ... | ... | @@ -291,8 +291,8 @@ |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | ids->in_use++; |
| 294 | - if (idx > ids->max_id) | |
| 295 | - ids->max_id = idx; | |
| 294 | + if (idx > ids->max_idx) | |
| 295 | + ids->max_idx = idx; | |
| 296 | 296 | return idx; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | |
| 300 | 300 | |
| 301 | 301 | |
| 302 | 302 | |
| ... | ... | @@ -431,20 +431,20 @@ |
| 431 | 431 | */ |
| 432 | 432 | void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp) |
| 433 | 433 | { |
| 434 | - int lid = ipcid_to_idx(ipcp->id); | |
| 434 | + int idx = ipcid_to_idx(ipcp->id); | |
| 435 | 435 | |
| 436 | - idr_remove(&ids->ipcs_idr, lid); | |
| 436 | + idr_remove(&ids->ipcs_idr, idx); | |
| 437 | 437 | ipc_kht_remove(ids, ipcp); |
| 438 | 438 | ids->in_use--; |
| 439 | 439 | ipcp->deleted = true; |
| 440 | 440 | |
| 441 | - if (unlikely(lid == ids->max_id)) { | |
| 441 | + if (unlikely(idx == ids->max_idx)) { | |
| 442 | 442 | do { |
| 443 | - lid--; | |
| 444 | - if (lid == -1) | |
| 443 | + idx--; | |
| 444 | + if (idx == -1) | |
| 445 | 445 | break; |
| 446 | - } while (!idr_find(&ids->ipcs_idr, lid)); | |
| 447 | - ids->max_id = lid; | |
| 446 | + } while (!idr_find(&ids->ipcs_idr, idx)); | |
| 447 | + ids->max_idx = idx; | |
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | |
| ... | ... | @@ -564,9 +564,9 @@ |
| 564 | 564 | struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id) |
| 565 | 565 | { |
| 566 | 566 | struct kern_ipc_perm *out; |
| 567 | - int lid = ipcid_to_idx(id); | |
| 567 | + int idx = ipcid_to_idx(id); | |
| 568 | 568 | |
| 569 | - out = idr_find(&ids->ipcs_idr, lid); | |
| 569 | + out = idr_find(&ids->ipcs_idr, idx); | |
| 570 | 570 | if (!out) |
| 571 | 571 | return ERR_PTR(-EINVAL); |
| 572 | 572 |
ipc/util.h
| ... | ... | @@ -113,12 +113,12 @@ |
| 113 | 113 | int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flg); |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | - * ipc_get_maxid - get the last assigned id | |
| 116 | + * ipc_get_maxidx - get the highest assigned index | |
| 117 | 117 | * @ids: ipc identifier set |
| 118 | 118 | * |
| 119 | 119 | * Called with ipc_ids.rwsem held for reading. |
| 120 | 120 | */ |
| 121 | -static inline int ipc_get_maxid(struct ipc_ids *ids) | |
| 121 | +static inline int ipc_get_maxidx(struct ipc_ids *ids) | |
| 122 | 122 | { |
| 123 | 123 | if (ids->in_use == 0) |
| 124 | 124 | return -1; |
| ... | ... | @@ -126,7 +126,7 @@ |
| 126 | 126 | if (ids->in_use == IPCMNI) |
| 127 | 127 | return IPCMNI - 1; |
| 128 | 128 | |
| 129 | - return ids->max_id; | |
| 129 | + return ids->max_idx; | |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /* |
| 133 | 133 | |
| ... | ... | @@ -172,9 +172,9 @@ |
| 172 | 172 | extern struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst); |
| 173 | 173 | extern int store_msg(void __user *dest, struct msg_msg *msg, size_t len); |
| 174 | 174 | |
| 175 | -static inline int ipc_checkid(struct kern_ipc_perm *ipcp, int uid) | |
| 175 | +static inline int ipc_checkid(struct kern_ipc_perm *ipcp, int id) | |
| 176 | 176 | { |
| 177 | - return uid / SEQ_MULTIPLIER != ipcp->seq; | |
| 177 | + return ipcid_to_seqx(id) != ipcp->seq; | |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | static inline void ipc_lock_object(struct kern_ipc_perm *perm) |