Skip to content

ipc: Clamp msgmni and shmmni to the real IPC_MNI limit

Waiman Long linux-fsdevel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3sysctl: Add range clamping intvec helper functionsinclude/linux/sysctl.h kernel/sysctl.c+96 -72 replies
2/3sysctl: Warn when a clamped sysctl parameter is set out of rangekernel/sysctl.c+34 -85 replies
3/3ipc: Clamp msgmni and shmmni to the real IPC_MNI limitipc/ipc_sysctl.c+7 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] ipc: Clamp msgmni and shmmni to the real IPC_MNI limit

The sysctl parameters msgmni and shmmni 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.

Enforcing the limit by failing sysctl parameter write, however, can break existing user applications. To address this delemma, the following new sysctl range clamping APIs are added:
- proc_dointvec_clamp_minmax()
- proc_douintvec_clamp_minmax()

This new set of APIs is then used to set the real limit for msgmni and shmmni without breaking existing applications. If any out of range value is written to those sysctl parameters, the following warning will be printed instead.

Kernel parameter "shmmni" was set out of range [0, 32768], clamped to 32768.

Reading the values back will show 32768 instead of some fake values.

Waiman Long (3):
sysctl: Add range clamping intvec helper functions
sysctl: Warn when a clamped sysctl parameter is set out of range
ipc: Clamp msgmni and shmmni to the real IPC_MNI limit

 include/linux/sysctl.h |   6 +++
 ipc/ipc_sysctl.c       |  10 ++--
 kernel/sysctl.c        | 123 ++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 129 insertions(+), 10 deletions(-)
Signature · 1 line
1.8.3.1