diff options
author | Manfred Spraul <manfred@colorfullife.com> | 2014-12-12 19:58:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-13 15:42:52 -0500 |
commit | e843e7d2c88b7db107a86bd2c7145dc715c058f4 (patch) | |
tree | 01557305cc1446467c9e70ba287f9b0360c9e1ce | |
parent | 2e094abfd1f29a08a60523b42d4508281b8dee0e (diff) |
ipc/sem.c: increase SEMMSL, SEMMNI, SEMOPM
a)
SysV can be abused to allocate 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 so that all known applications
will work with these defaults.
b)
With regards to the maximum supported:
Some of the specified hard limits are not correct anymore, therefore the
patch updates the documentation.
- 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.
Therefore: Leave it at 500 (order=0 allocation).
Note:
If an administrator must limit the memory allocations, then he can set the
values as necessary.
Or he can disable sysv entirely (as e.g. done by Android).
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Acked-by: Rafael Aquini <aquini@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/uapi/linux/sem.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/include/uapi/linux/sem.h b/include/uapi/linux/sem.h index 541fce03b50c..dd73b908b2f3 100644 --- a/include/uapi/linux/sem.h +++ b/include/uapi/linux/sem.h | |||
@@ -63,10 +63,22 @@ struct seminfo { | |||
63 | int semaem; | 63 | int semaem; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | #define SEMMNI 128 /* <= IPCMNI max # of semaphore identifiers */ | 66 | /* |
67 | #define SEMMSL 250 /* <= 8 000 max num of semaphores per id */ | 67 | * SEMMNI, SEMMSL and SEMMNS are default values which can be |
68 | * modified by sysctl. | ||
69 | * The values has been chosen to be larger than necessary for any | ||
70 | * known configuration. | ||
71 | * | ||
72 | * SEMOPM should not be increased beyond 1000, otherwise there is the | ||
73 | * risk that semop()/semtimedop() fails due to kernel memory fragmentation when | ||
74 | * allocating the sop array. | ||
75 | */ | ||
76 | |||
77 | |||
78 | #define SEMMNI 32000 /* <= IPCMNI max # of semaphore identifiers */ | ||
79 | #define SEMMSL 32000 /* <= INT_MAX max num of semaphores per id */ | ||
68 | #define SEMMNS (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */ | 80 | #define SEMMNS (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */ |
69 | #define SEMOPM 32 /* <= 1 000 max num of ops per semop call */ | 81 | #define SEMOPM 500 /* <= 1 000 max num of ops per semop call */ |
70 | #define SEMVMX 32767 /* <= 32767 semaphore maximum value */ | 82 | #define SEMVMX 32767 /* <= 32767 semaphore maximum value */ |
71 | #define SEMAEM SEMVMX /* adjust on exit max value */ | 83 | #define SEMAEM SEMVMX /* adjust on exit max value */ |
72 | 84 | ||