mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Davidlohr Bueso <davidlohr.bueso@hp.com>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	Rafael Aquini <aquini@redhat.com>, Rik van Riel <riel@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	1vier1@web.de, Manfred Spraul <manfred@colorfullife.com>
Subject: [PATCH 2/3] ipc/sem.c: increase SEMMSL, SEMMNI, SEMOPM
Date: Thu, 29 May 2014 20:46:39 +0200	[thread overview]
Message-ID: <1401389200-6758-3-git-send-email-manfred@colorfullife.com> (raw)
In-Reply-To: <1401389200-6758-2-git-send-email-manfred@colorfullife.com>

SysV can be abused to allocated locked kernel memory.
For most systems, a small limit doesn't make sense,
see the discussion with regards to SHMMAX.

Therefore: Increase the sysv sem limits to the maximum supported.

With regards to the maximum supported:
Some of the specified hard limits are not correct anymore.

Therefore here is an updated list:

- SEMMNI must stay below IPCMNI, which is 32768.
  As for SHMMAX: Stay a bit below this limit.

- SEMMSL was limited to 8k, to ensure that the kmalloc for the
  kernel array was limited to 16 kB (order=2)

  This doesn't apply anymore:
   - the allocation size isn't sizeof(short)*nsems anymore.
   - ipc_alloc falls back to vmalloc

- SEMOPM should stay below 1000, to limit the kmalloc in
  semtimedop() to an order=1 allocation.

  This might be a real issue: The Redhat documentation
  shows an example with SEMOPM=5010:

https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/sect-Oracle_9i_and_10g_Tuning_Guide-Setting_Semaphores-An_Example_of_Semaphore_Settings.html

  If Oracle really uses operations with SEMOPM 5000 and larger, then
  semtimedop() should be converted from kmalloc to ipc_alloc.

Note:
If an administrator must limit the memory allocations, then
he can set MSGMNI as necessary.

Or he can disable sysv entirely (as e.g. done with Android).
---
 include/uapi/linux/sem.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/uapi/linux/sem.h b/include/uapi/linux/sem.h
index 541fce0..a4f47d9 100644
--- a/include/uapi/linux/sem.h
+++ b/include/uapi/linux/sem.h
@@ -63,10 +63,10 @@ struct  seminfo {
 	int semaem;
 };
 
-#define SEMMNI  128             /* <= IPCMNI  max # of semaphore identifiers */
-#define SEMMSL  250             /* <= 8 000 max num of semaphores per id */
+#define SEMMNI  32000           /* <= IPCMNI  max # of semaphore identifiers */
+#define SEMMSL  32000           /* <= INT_MAX max num of semaphores per id */
 #define SEMMNS  (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */
-#define SEMOPM  32	        /* <= 1 000 max num of ops per semop call */
+#define SEMOPM  1000	        /* <= 1 000 max num of ops per semop call */
 #define SEMVMX  32767           /* <= 32767 semaphore maximum value */
 #define SEMAEM  SEMVMX          /* adjust on exit max value */
 
-- 
1.9.3


  reply	other threads:[~2014-05-29 18:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-29 18:46 [PATCH 0/3] ipc: Further updates to sysv/mqueue limits Manfred Spraul
2014-05-29 18:46 ` [PATCH 1/3] ipc/msg: increase MSGMNI, remove scaling Manfred Spraul
2014-05-29 18:46   ` Manfred Spraul [this message]
2014-05-29 18:46     ` [PATCH 3/3] ipc namespace: copy settings from parent namespace Manfred Spraul
2014-06-05 12:54       ` Michael Kerrisk (man-pages)
2014-06-06 13:57         ` Serge E. Hallyn
2014-05-31  5:20 ` [PATCH 0/3] ipc: Further updates to sysv/mqueue limits Michael Kerrisk (man-pages)
2014-08-12  7:29 Manfred Spraul
2014-08-12  7:29 ` [PATCH 1/3] ipc/msg: increase MSGMNI, remove scaling Manfred Spraul
2014-08-12  7:29   ` [PATCH 2/3] ipc/sem.c: increase SEMMSL, SEMMNI, SEMOPM Manfred Spraul
2014-08-15 13:42     ` Rafael Aquini
2014-10-06 18:32 [PATCH 0/3] Misc updates to sysv ipc Manfred Spraul
2014-10-06 18:32 ` [PATCH 1/3] ipc/sem.c: Chance memory barrier in sem_lock() to smp_rmb() Manfred Spraul
2014-10-06 18:32   ` [PATCH 2/3] ipc/sem.c: increase SEMMSL, SEMMNI, SEMOPM Manfred Spraul
2014-10-07 20:09     ` Rafael Aquini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1401389200-6758-3-git-send-email-manfred@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=1vier1@web.de \
    --cc=aquini@redhat.com \
    --cc=davidlohr.bueso@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=riel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®