ipc: Add a new ipcmni_compat sysctl to fall back to old behavior
Subsystems (2)
PATCH RESEND v8 5/5 ipc: Add a new ipcmni_compat sysctl to fall back to old behavior
With strict range limit enforcement of msgmni, shmmni and sem, it is possible that some existing applications that set those values to above 32k may fail. To help users to work around this potential problem, a new boolean ipcmni_compat sysctl is added to provide the old beahavior for compatibility when it is set to 1. In other word, the limit will then be enforced internally but no error will be reported.
This compatibility mode can only be enabled if the ipcmni_extend kernel boot parameter is not specified.
The sysctl documentation is also updated accordingly.
RESEND: Add missing ipcmni_max macro in util.h.
Signed-off-by Waiman Long <[email protected]>
--- Documentation/sysctl/kernel.txt | 15 +++++++++++++++ ipc/ipc_sysctl.c | 42 ++++++++++++++++++++++++++++++++++++++--- ipc/util.h | 6 ++++-- 3 files changed, 58 insertions(+), 5 deletions(-)
Documentation/sysctl/kernel.txt +15 -0
@@ -39,6 +39,7 @@ show up in /proc/sys/kernel: - hung_task_check_count - hung_task_timeout_secs - hung_task_warnings +- ipcmni_compat - kexec_load_disabled - kptr_restrict - l2cr [ PPC only ]
@@ -374,6 +375,20 @@ This file shows up if CONFIG_DETECT_HUNG_TASK is enabled. ============================================================== +ipcmni_compat: + +A boolean flag to control range checking behavior of msgmni, shmmni +and the mni portion of sem. + +0: Range limits will be strictly enforced and error will be returned + if limits are exceeded. +1: Range limits will only be enforced internally and no error will be + returned if the upper limit is exceeded. This compatibility behavior + can only be selected if the ipcmni_extend kernel boot parameter is + not specified. + +============================================================== + kexec_load_disabled: A toggle indicating if the kexec_load syscall has been disabled. This
ipc/ipc_sysctl.c +39 -3
89 lines not on this page · raw message
ipc/util.h +4 -2
@@ -29,6 +29,7 @@#ifdef CONFIG_SYSVIPC_SYSCTL extern int ipc_mni;extern int ipc_mni_shift; +extern int ipcmni_max;extern bool ipc_mni_extended;#define SEQ_SHIFT ipc_mni_shift
@@ -38,6 +39,7 @@#define ipc_mni IPCMNI#define ipc_mni_extended false +#define ipcmni_max IPCMNI#define SEQ_SHIFT IPCMNI_SHIFT#define SEQ_MASK ((1 << IPCMNI_SHIFT) - 1)#endif /* CONFIG_SYSVIPC_SYSCTL */
@@ -244,10 +246,10 @@ void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,static inline int sem_check_semmni (struct ipc_namespace *ns) {/* -* Check semmni range [0, ipc_mni] +* Check semmni range [0, ipcmni_max] * semmni is the last element of sem_ctls[4] array */ -return ((ns->sem_ctls[3 ] <0 ) || (ns->sem_ctls[3 ] > ipc_mni)) +return ((ns->sem_ctls[3 ] <0 ) || (ns->sem_ctls[3 ] > ipcmni_max)) ? -ERANGE :0 ; }
Signature · 1 line
1.8.3.1