mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 15:54:15 +08:00
f3713fd9cf
Commit 93e6f119c0
("ipc/mqueue: cleanup definition names and
locations") added global hardcoded limits to the amount of message
queues that can be created. While these limits are per-namespace,
reality is that it ends up breaking userspace applications.
Historically users have, at least in theory, been able to create up to
INT_MAX queues, and limiting it to just 1024 is way too low and dramatic
for some workloads and use cases. For instance, Madars reports:
"This update imposes bad limits on our multi-process application. As
our app uses approaches that each process opens its own set of queues
(usually something about 3-5 queues per process). In some scenarios
we might run up to 3000 processes or more (which of-course for linux
is not a problem). Thus we might need up to 9000 queues or more. All
processes run under one user."
Other affected users can be found in launchpad bug #1155695:
https://bugs.launchpad.net/ubuntu/+source/manpages/+bug/1155695
Instead of increasing this limit, revert it entirely and fallback to the
original way of dealing queue limits -- where once a user's resource
limit is reached, and all memory is used, new queues cannot be created.
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Reported-by: Madars Vitolins <m@silodev.com>
Acked-by: Doug Ledford <dledford@redhat.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: <stable@vger.kernel.org> [3.5+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
125 lines
2.9 KiB
C
125 lines
2.9 KiB
C
/*
|
|
* Copyright (C) 2007 IBM Corporation
|
|
*
|
|
* Author: Cedric Le Goater <clg@fr.ibm.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation, version 2 of the
|
|
* License.
|
|
*/
|
|
|
|
#include <linux/nsproxy.h>
|
|
#include <linux/ipc_namespace.h>
|
|
#include <linux/sysctl.h>
|
|
|
|
#ifdef CONFIG_PROC_SYSCTL
|
|
static void *get_mq(ctl_table *table)
|
|
{
|
|
char *which = table->data;
|
|
struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
|
|
which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
|
|
return which;
|
|
}
|
|
|
|
static int proc_mq_dointvec(ctl_table *table, int write,
|
|
void __user *buffer, size_t *lenp, loff_t *ppos)
|
|
{
|
|
struct ctl_table mq_table;
|
|
memcpy(&mq_table, table, sizeof(mq_table));
|
|
mq_table.data = get_mq(table);
|
|
|
|
return proc_dointvec(&mq_table, write, buffer, lenp, ppos);
|
|
}
|
|
|
|
static int proc_mq_dointvec_minmax(ctl_table *table, int write,
|
|
void __user *buffer, size_t *lenp, loff_t *ppos)
|
|
{
|
|
struct ctl_table mq_table;
|
|
memcpy(&mq_table, table, sizeof(mq_table));
|
|
mq_table.data = get_mq(table);
|
|
|
|
return proc_dointvec_minmax(&mq_table, write, buffer,
|
|
lenp, ppos);
|
|
}
|
|
#else
|
|
#define proc_mq_dointvec NULL
|
|
#define proc_mq_dointvec_minmax NULL
|
|
#endif
|
|
|
|
static int msg_max_limit_min = MIN_MSGMAX;
|
|
static int msg_max_limit_max = HARD_MSGMAX;
|
|
|
|
static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
|
|
static int msg_maxsize_limit_max = HARD_MSGSIZEMAX;
|
|
|
|
static ctl_table mq_sysctls[] = {
|
|
{
|
|
.procname = "queues_max",
|
|
.data = &init_ipc_ns.mq_queues_max,
|
|
.maxlen = sizeof(int),
|
|
.mode = 0644,
|
|
.proc_handler = proc_mq_dointvec,
|
|
},
|
|
{
|
|
.procname = "msg_max",
|
|
.data = &init_ipc_ns.mq_msg_max,
|
|
.maxlen = sizeof(int),
|
|
.mode = 0644,
|
|
.proc_handler = proc_mq_dointvec_minmax,
|
|
.extra1 = &msg_max_limit_min,
|
|
.extra2 = &msg_max_limit_max,
|
|
},
|
|
{
|
|
.procname = "msgsize_max",
|
|
.data = &init_ipc_ns.mq_msgsize_max,
|
|
.maxlen = sizeof(int),
|
|
.mode = 0644,
|
|
.proc_handler = proc_mq_dointvec_minmax,
|
|
.extra1 = &msg_maxsize_limit_min,
|
|
.extra2 = &msg_maxsize_limit_max,
|
|
},
|
|
{
|
|
.procname = "msg_default",
|
|
.data = &init_ipc_ns.mq_msg_default,
|
|
.maxlen = sizeof(int),
|
|
.mode = 0644,
|
|
.proc_handler = proc_mq_dointvec_minmax,
|
|
.extra1 = &msg_max_limit_min,
|
|
.extra2 = &msg_max_limit_max,
|
|
},
|
|
{
|
|
.procname = "msgsize_default",
|
|
.data = &init_ipc_ns.mq_msgsize_default,
|
|
.maxlen = sizeof(int),
|
|
.mode = 0644,
|
|
.proc_handler = proc_mq_dointvec_minmax,
|
|
.extra1 = &msg_maxsize_limit_min,
|
|
.extra2 = &msg_maxsize_limit_max,
|
|
},
|
|
{}
|
|
};
|
|
|
|
static ctl_table mq_sysctl_dir[] = {
|
|
{
|
|
.procname = "mqueue",
|
|
.mode = 0555,
|
|
.child = mq_sysctls,
|
|
},
|
|
{}
|
|
};
|
|
|
|
static ctl_table mq_sysctl_root[] = {
|
|
{
|
|
.procname = "fs",
|
|
.mode = 0555,
|
|
.child = mq_sysctl_dir,
|
|
},
|
|
{}
|
|
};
|
|
|
|
struct ctl_table_header *mq_register_sysctl_table(void)
|
|
{
|
|
return register_sysctl_table(mq_sysctl_root);
|
|
}
|