The vfs_cache_min_ratio sysctl was registered with .extra1 = SYSCTL_ZERO
and .extra2 = SYSCTL_ONE_HUNDRED but with .proc_handler = proc_dointvec.
proc_dointvec ignores extra1/extra2, so the intended [0, 100] clamp was
never applied and any value (e.g. 101 or negative via a different path)
was accepted. The value is used as a percentage in fs/super.c
(vfs_cache_min_ratio * total / 100), where out-of-range values give a
nonsensical protected-cache size.

Use proc_dointvec_minmax so the already-declared bounds are honoured and
an out-of-range write is rejected with -EINVAL.

Fixes: 699a98562e4f ("ve/mm: introduce min threshold for dcache")
Feature: mm: threshold for minimal dcache amount
https://virtuozzo.atlassian.net/browse/VSTOR-137234
Signed-off-by: Konstantin Khorenko <[email protected]>
---
 kernel/sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 8bb2c2de769e..cd2d91dca858 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2161,7 +2161,7 @@ static struct ctl_table vm_table[] = {
                .data           = &sysctl_vfs_cache_min_ratio,
                .maxlen         = sizeof(sysctl_vfs_cache_min_ratio),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = proc_dointvec_minmax,
                .extra1         = SYSCTL_ZERO,
                .extra2         = SYSCTL_ONE_HUNDRED,
        },
-- 
2.47.1

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to