diff options
-rw-r--r-- | include/linux/ipc_namespace.h | 1 | ||||
-rw-r--r-- | ipc/util.c | 13 | ||||
-rw-r--r-- | ipc/util.h | 1 |
3 files changed, 3 insertions, 12 deletions
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index f6c82de1254..e7831d20373 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h @@ -21,7 +21,6 @@ struct user_namespace; struct ipc_ids { int in_use; unsigned short seq; - unsigned short seq_max; struct rw_semaphore rwsem; struct idr ipcs_idr; int next_id; diff --git a/ipc/util.c b/ipc/util.c index cecb46e89ab..e1b4c6db8aa 100644 --- a/ipc/util.c +++ b/ipc/util.c @@ -139,19 +139,10 @@ __initcall(ipc_init); */ void ipc_init_ids(struct ipc_ids *ids) { - init_rwsem(&ids->rwsem); - ids->in_use = 0; ids->seq = 0; ids->next_id = -1; - { - int seq_limit = INT_MAX/SEQ_MULTIPLIER; - if (seq_limit > USHRT_MAX) - ids->seq_max = USHRT_MAX; - else - ids->seq_max = seq_limit; - } - + init_rwsem(&ids->rwsem); idr_init(&ids->ipcs_idr); } @@ -304,7 +295,7 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size) if (next_id < 0) { new->seq = ids->seq++; - if (ids->seq > ids->seq_max) + if (ids->seq > IPCID_SEQ_MAX) ids->seq = 0; } else { new->seq = ipcid_to_seqx(next_id); diff --git a/ipc/util.h b/ipc/util.h index d64db3e56f7..9c47d6f6c7b 100644 --- a/ipc/util.h +++ b/ipc/util.h @@ -100,6 +100,7 @@ void __init ipc_init_proc_interface(const char *path, const char *header, #define ipcid_to_idx(id) ((id) % SEQ_MULTIPLIER) #define ipcid_to_seqx(id) ((id) / SEQ_MULTIPLIER) +#define IPCID_SEQ_MAX min_t(int, INT_MAX/SEQ_MULTIPLIER, USHRT_MAX) /* must be called with ids->rwsem acquired for writing */ int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int); |