[Devel] [PATCH vz10 04/24] ve/mm: enforce the 0..100 bound on vfs_cache_min_ratio

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Jul 23 15:25:07 MSK 2026


Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

On 7/6/26 12:59, Konstantin Khorenko wrote:
> 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 <khorenko at virtuozzo.com>
> ---
>  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,
>  	},

-- 
Best regards, Pavel Tikhomirov
Senior Software Developer, Virtuozzo.



More information about the Devel mailing list