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

Submitted by Konstantin Khorenko on Aug. 11, 2017, 8:51 a.m.

Details

Message ID 1502441465-4007-3-git-send-email-khorenko@virtuozzo.com
State New
Series "ve/fs/mount: make work with ve->mnt_nr race free"
Headers show

Commit Message

Konstantin Khorenko Aug. 11, 2017, 8:51 a.m.
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>
---
 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 }
 };