]> git.ipfire.org Git - thirdparty/linux.git/commit
ipvs: clear the svc scheduler ptr early on edit
authorJulian Anastasov <ja@ssi.bg>
Mon, 25 May 2026 04:07:44 +0000 (07:07 +0300)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 1 Jun 2026 11:43:52 +0000 (13:43 +0200)
commit193989cc6d80dd8e0460fb3992e69fa03bf0ff9b
tree8caf4738a8ff006a23298f457eccb0744187df88
parentc6c5327dd18bec1e1bbf139b2cf5ae53608a9d30
ipvs: clear the svc scheduler ptr early on edit

ip_vs_edit_service() while unbinding the old scheduler clears
the svc->scheduler ptr after the scheduler module initiates
RCU callbacks. This can cause packets to use the old
scheduler at the time when svc->sched_data is already freed
after RCU grace period.

Fix it by clearing the ptr early in ip_vs_unbind_scheduler(),
before the done_service method schedules any RCU callbacks.

Also, if the new scheduler fails to initialize when replacing
the old scheduler, try to restore the old scheduler while still
returning the error code.

Link: https://sashiko.dev/#/patchset/20260519015506.634185-1-rosenp%40gmail.com
Fixes: 05f00505a89a ("ipvs: fix crash if scheduler is changed")
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/ip_vs.h
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/ipvs/ip_vs_sched.c