Skip to content

Commit

Permalink
ipc: IPCMNI limit check for msgmni and shmmni
Browse files Browse the repository at this point in the history
Patch series "ipc: IPCMNI limit check for *mni & increase that limit", v9.

The sysctl parameters msgmni, shmmni and semmni have an inherent limit of
IPC_MNI (32k).  However, users may not be aware of that because they can
write a value much higher than that without getting any error or
notification.  Reading the parameters back will show the newly written
values which are not real.

The real IPCMNI limit is now enforced to make sure that users won't put in
an unrealistic value.  The first 2 patches enforce the limits.

There are also users out there requesting increase in the IPCMNI value.
The last 2 patches attempt to do that by using a boot kernel parameter
"ipcmni_extend" to increase the IPCMNI limit from 32k to 8M if the users
really want the extended value.

This patch (of 4):

A user can write arbitrary integer values to msgmni and shmmni sysctl
parameters without getting error, but the actual limit is really IPCMNI
(32k).  This can mislead users as they think they can get a value that is
not real.

The right limits are now set for msgmni and shmmni so that the users will
become aware if they set a value outside of the acceptable range.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Waiman Long <[email protected]>
Acked-by: Luis R. Rodriguez <[email protected]>
Reviewed-by: Davidlohr Bueso <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Takashi Iwai <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Waiman-Long authored and torvalds committed Oct 31, 2018
1 parent b49dec1 commit 6730e65
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ipc/ipc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ static int proc_ipc_auto_msgmni(struct ctl_table *table, int write,
static int zero;
static int one = 1;
static int int_max = INT_MAX;
static int ipc_mni = IPCMNI;

static struct ctl_table ipc_kern_table[] = {
{
Expand All @@ -120,7 +121,9 @@ static struct ctl_table ipc_kern_table[] = {
.data = &init_ipc_ns.shm_ctlmni,
.maxlen = sizeof(init_ipc_ns.shm_ctlmni),
.mode = 0644,
.proc_handler = proc_ipc_dointvec,
.proc_handler = proc_ipc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &ipc_mni,
},
{
.procname = "shm_rmid_forced",
Expand All @@ -147,7 +150,7 @@ static struct ctl_table ipc_kern_table[] = {
.mode = 0644,
.proc_handler = proc_ipc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &int_max,
.extra2 = &ipc_mni,
},
{
.procname = "auto_msgmni",
Expand Down

0 comments on commit 6730e65

Please sign in to comment.