LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

Re: [PATCHv3 net] ipvs: fix races around est_mutex and est_cpulist

To: Simon Horman <horms@xxxxxxxxxxxx>
Subject: Re: [PATCHv3 net] ipvs: fix races around est_mutex and est_cpulist
Cc: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>, Florian Westphal <fw@xxxxxxxxx>, lvs-devel@xxxxxxxxxxxxxxx, netfilter-devel@xxxxxxxxxxxxxxx
From: Julian Anastasov <ja@xxxxxx>
Date: Fri, 24 Apr 2026 22:41:54 +0300 (EEST)
        Hello,

On Fri, 24 Apr 2026, Julian Anastasov wrote:

> Sashiko reports for races and possible crash around
> the usage of est_cpulist_valid and sysctl_est_cpulist.
> The problem is that we do not lock est_mutex in some
> places which can lead to wrong write ordering and
> as result problems when calling cpumask_weight()
> and cpumask_empty().
> 
> Fix them by moving the est_max_threads read/write under
> locked est_mutex. Do the same for one ip_vs_est_reload_start()
> call to protect the cpumask_empty() usage of sysctl_est_cpulist.
> 
> To remove the chance of deadlock while stopping the
> estimation kthreads, keep the data structure for kthread 0
> even after last estimator is removed and do not hold mutexes
> while stopping this task. Now we will use a new flag 'needed'
> to know when kthread 0 should run. The kthreads above 0
> do not use mutexes, so stop them under est_mutex because
> their kthread data still can be destroyed if they do not
> serve estimators. Now all kthreads will be started by
> the est_reload_work to properly serialize the stop/start
> for kthread 0.
> 
> Reduce the use of service_mutex in ip_vs_est_calc_limits()
> because under est_mutex we can safely walk est_kt_arr to
> stop the kthreads above slot 0.
> 
> Link: 
> https://sashiko.dev/#/patchset/20260331165015.2777765-1-longman%40redhat.com
> Link: https://sashiko.dev/#/patchset/20260420171308.87192-1-ja%40ssi.bg
> Link: https://sashiko.dev/#/patchset/20260422125123.40658-1-ja%40ssi.bg
> Fixes: f0be83d54217 ("ipvs: add est_cpulist and est_nice sysctl vars")
> Signed-off-by: Julian Anastasov <ja@xxxxxx>

        Sashiko found another use-after-free [1] that is easy to
fix here. I'll send new patch version tomorrow...

pw-bot: changes-requested

[1] https://sashiko.dev/#/patchset/20260424175858.54752-1-ja%40ssi.bg

Regards

--
Julian Anastasov <ja@xxxxxx>



<Prev in Thread] Current Thread [Next in Thread>