[PATCH] ipvs: skip committing sync_threshold when proc_dointvec fails

Joel Granados posted 1 patch 2 days, 6 hours ago
net/netfilter/ipvs/ip_vs_ctl.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] ipvs: skip committing sync_threshold when proc_dointvec fails
Posted by Joel Granados 2 days, 6 hours ago
Forward rc value and skip updating sysctl_sync_threshold when
proc_dointvec fails. This targets a write such as "5 x" which would fail
with -EINVAL but would store the first element anyway.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
 net/netfilter/ipvs/ip_vs_ctl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 4c1c739446b76ea455dab2958a844d05e31a46a7..7c260529238cd2015f1d30abd094d25b056b30fa 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -2454,6 +2454,8 @@ proc_do_sync_threshold(const struct ctl_table *table, int write,
 	mutex_lock(&ipvs->sync_mutex);
 	memcpy(val, valp, sizeof(val));
 	rc = proc_dointvec(&tmp, write, buffer, lenp, ppos);
+	if (rc)
+		goto out;
 	if (write) {
 		if (val[0] < 0 || val[1] < 0 ||
 		    (val[0] >= val[1] && val[1]))
@@ -2461,6 +2463,7 @@ proc_do_sync_threshold(const struct ctl_table *table, int write,
 		else
 			memcpy(valp, val, sizeof(val));
 	}
+out:
 	mutex_unlock(&ipvs->sync_mutex);
 	return rc;
 }

---
base-commit: 93f51579e7df248780214094418f205253383cc5
change-id: 20260922-lklm-sysctl-retval-fix-abad29dc37bd

Best regards,
-- 
Joel Granados <joel.granados@kernel.org>
Re: [PATCH] ipvs: skip committing sync_threshold when proc_dointvec fails
Posted by Julian Anastasov 1 day, 22 hours ago
	Hello,

On Tue, 22 Sep 2026, Joel Granados wrote:

> Forward rc value and skip updating sysctl_sync_threshold when
> proc_dointvec fails. This targets a write such as "5 x" which would fail
> with -EINVAL but would store the first element anyway.
> 
> Signed-off-by: Joel Granados <joel.granados@kernel.org>

	Looks good to me for the nf tree, thanks!

Acked-by: Julian Anastasov <ja@ssi.bg>

> ---
>  net/netfilter/ipvs/ip_vs_ctl.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index 4c1c739446b76ea455dab2958a844d05e31a46a7..7c260529238cd2015f1d30abd094d25b056b30fa 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -2454,6 +2454,8 @@ proc_do_sync_threshold(const struct ctl_table *table, int write,
>  	mutex_lock(&ipvs->sync_mutex);
>  	memcpy(val, valp, sizeof(val));
>  	rc = proc_dointvec(&tmp, write, buffer, lenp, ppos);
> +	if (rc)
> +		goto out;
>  	if (write) {
>  		if (val[0] < 0 || val[1] < 0 ||
>  		    (val[0] >= val[1] && val[1]))
> @@ -2461,6 +2463,7 @@ proc_do_sync_threshold(const struct ctl_table *table, int write,
>  		else
>  			memcpy(valp, val, sizeof(val));
>  	}
> +out:
>  	mutex_unlock(&ipvs->sync_mutex);
>  	return rc;
>  }
> 
> ---
> base-commit: 93f51579e7df248780214094418f205253383cc5
> change-id: 20260922-lklm-sysctl-retval-fix-abad29dc37bd
> 
> Best regards,
> -- 
> Joel Granados <joel.granados@kernel.org>

Regards

--
Julian Anastasov <ja@ssi.bg>