[Devel,RHEL7,COMMIT] ve/fs: limit "fs.ve-mount-nr" sysctl with INT_MAX

Submitted by Konstantin Khorenko on Aug. 11, 2017, 2:50 p.m.

Details

Message ID 201708111450.v7BEoB57005594@finist_cl7.x64_64.work.ct
State New
Series "ve/fs/mount: make work with ve->mnt_nr race free"
Headers show

Commit Message

Konstantin Khorenko Aug. 11, 2017, 2:50 p.m.
The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.35.3
------>
commit 22157fffc0aa97358cdaba5b309a700037af2a65
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
Date:   Fri Aug 11 18:50:11 2017 +0400

    ve/fs: limit "fs.ve-mount-nr" sysctl with INT_MAX
    
    sysctl "fs.ve-mount-nr" is unsigned int and is casted to "int" while
    comparing values => if we set it to a value > INT_MAX, VE won't be able to
    mount anything after that.
    => set a max value for sysctl == INT_MAX
    
    https://jira.sw.ru/browse/PSBM-69880
    
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 kernel/ve/veowner.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/kernel/ve/veowner.c b/kernel/ve/veowner.c
index 8df6390..a7fe9cc 100644
--- a/kernel/ve/veowner.c
+++ b/kernel/ve/veowner.c
@@ -83,6 +83,8 @@  static void prepare_proc(void)
  * points for a VE.
  */
 unsigned int sysctl_ve_mount_nr = 4096;
+static int ve_mount_nr_min = 0;
+static int ve_mount_nr_max = INT_MAX;
 
 static struct ctl_table vz_fs_table[] = {
 	{
@@ -97,7 +99,9 @@  static struct ctl_table vz_fs_table[] = {
 		.data           = &sysctl_ve_mount_nr,
 		.maxlen         = sizeof(sysctl_ve_mount_nr),
 		.mode           = 0644,
-		.proc_handler   = proc_dointvec,
+		.proc_handler   = proc_dointvec_minmax,
+		.extra1		= &ve_mount_nr_min,
+		.extra2		= &ve_mount_nr_max,
 	},
 	{ 0 }
 };