aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/sysctl/fs.txt7
-rw-r--r--include/linux/ipc_namespace.h2
-rw-r--r--ipc/mq_sysctl.c18
-rw-r--r--ipc/mqueue.c9
4 files changed, 33 insertions, 3 deletions
diff --git a/Documentation/sysctl/fs.txt b/Documentation/sysctl/fs.txt
index 88fd7f5c8dcd..13d6166d7a27 100644
--- a/Documentation/sysctl/fs.txt
+++ b/Documentation/sysctl/fs.txt
@@ -225,6 +225,13 @@ a queue must be less or equal then msg_max.
225maximum message size value (it is every message queue's attribute set during 225maximum message size value (it is every message queue's attribute set during
226its creation). 226its creation).
227 227
228/proc/sys/fs/mqueue/msg_default is a read/write file for setting/getting the
229default number of messages in a queue value if attr parameter of mq_open(2) is
230NULL. If it exceed msg_max, the default value is initialized msg_max.
231
232/proc/sys/fs/mqueue/msgsize_default is a read/write file for setting/getting
233the default message size value if attr parameter of mq_open(2) is NULL. If it
234exceed msgsize_max, the default value is initialized msgsize_max.
228 235
2294. /proc/sys/fs/epoll - Configuration options for the epoll interface 2364. /proc/sys/fs/epoll - Configuration options for the epoll interface
230-------------------------------------------------------- 237--------------------------------------------------------
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index 2488535a32a3..5499c92a9153 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -62,6 +62,8 @@ struct ipc_namespace {
62 unsigned int mq_queues_max; /* initialized to DFLT_QUEUESMAX */ 62 unsigned int mq_queues_max; /* initialized to DFLT_QUEUESMAX */
63 unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */ 63 unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */
64 unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */ 64 unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */
65 unsigned int mq_msg_default;
66 unsigned int mq_msgsize_default;
65 67
66 /* user_ns which owns the ipc ns */ 68 /* user_ns which owns the ipc ns */
67 struct user_namespace *user_ns; 69 struct user_namespace *user_ns;
diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
index e22336a09b4a..383d638340b8 100644
--- a/ipc/mq_sysctl.c
+++ b/ipc/mq_sysctl.c
@@ -73,6 +73,24 @@ static ctl_table mq_sysctls[] = {
73 .extra1 = &msg_maxsize_limit_min, 73 .extra1 = &msg_maxsize_limit_min,
74 .extra2 = &msg_maxsize_limit_max, 74 .extra2 = &msg_maxsize_limit_max,
75 }, 75 },
76 {
77 .procname = "msg_default",
78 .data = &init_ipc_ns.mq_msg_default,
79 .maxlen = sizeof(int),
80 .mode = 0644,
81 .proc_handler = proc_mq_dointvec_minmax,
82 .extra1 = &msg_max_limit_min,
83 .extra2 = &msg_max_limit_max,
84 },
85 {
86 .procname = "msgsize_default",
87 .data = &init_ipc_ns.mq_msgsize_default,
88 .maxlen = sizeof(int),
89 .mode = 0644,
90 .proc_handler = proc_mq_dointvec_minmax,
91 .extra1 = &msg_maxsize_limit_min,
92 .extra2 = &msg_maxsize_limit_max,
93 },
76 {} 94 {}
77}; 95};
78 96
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 6828e2c93cef..609d53f7a915 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -145,9 +145,10 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
145 info->qsize = 0; 145 info->qsize = 0;
146 info->user = NULL; /* set when all is ok */ 146 info->user = NULL; /* set when all is ok */
147 memset(&info->attr, 0, sizeof(info->attr)); 147 memset(&info->attr, 0, sizeof(info->attr));
148 info->attr.mq_maxmsg = min(ipc_ns->mq_msg_max, DFLT_MSG); 148 info->attr.mq_maxmsg = min(ipc_ns->mq_msg_max,
149 info->attr.mq_msgsize = 149 ipc_ns->mq_msg_default);
150 min(ipc_ns->mq_msgsize_max, DFLT_MSGSIZE); 150 info->attr.mq_msgsize = min(ipc_ns->mq_msgsize_max,
151 ipc_ns->mq_msgsize_default);
151 if (attr) { 152 if (attr) {
152 info->attr.mq_maxmsg = attr->mq_maxmsg; 153 info->attr.mq_maxmsg = attr->mq_maxmsg;
153 info->attr.mq_msgsize = attr->mq_msgsize; 154 info->attr.mq_msgsize = attr->mq_msgsize;
@@ -1261,6 +1262,8 @@ int mq_init_ns(struct ipc_namespace *ns)
1261 ns->mq_queues_max = DFLT_QUEUESMAX; 1262 ns->mq_queues_max = DFLT_QUEUESMAX;
1262 ns->mq_msg_max = DFLT_MSGMAX; 1263 ns->mq_msg_max = DFLT_MSGMAX;
1263 ns->mq_msgsize_max = DFLT_MSGSIZEMAX; 1264 ns->mq_msgsize_max = DFLT_MSGSIZEMAX;
1265 ns->mq_msg_default = DFLT_MSG;
1266 ns->mq_msgsize_default = DFLT_MSGSIZE;
1264 1267
1265 ns->mq_mnt = kern_mount_data(&mqueue_fs_type, ns); 1268 ns->mq_mnt = kern_mount_data(&mqueue_fs_type, ns);
1266 if (IS_ERR(ns->mq_mnt)) { 1269 if (IS_ERR(ns->mq_mnt)) {