[Devel] [PATCH rh7 2/3] ve/fs: limit "fs.ve-mount-nr" sysctl with INT_MAX

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 11 11:51:04 MSK 2017


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 at virtuozzo.com>
---
 kernel/ve/veowner.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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 }
 };
-- 
1.8.3.1



More information about the Devel mailing list