Patch "ipvs: fix crash if scheduler is changed" has been added to the 4.1-stable tree
Subsystems (4)
This is a note to let you know that I've just added the patch titled
ipvs: fix crash if scheduler is changed
to the 4.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ipvs-fix-crash-if-scheduler-is-changed.patch
and it can be found in the queue-4.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
05f00505a89acd21f5d0d20f5797dfbc4cf85243Mon Sep 17 00:00:00 2001
From: Julian Anastasov <[email protected]>
Date: Mon, 29 Jun 2015 21:51:40 +0300
Subject: ipvs: fix crash if scheduler is changed
From: Julian Anastasov <[email protected]>
commit 05f00505a89acd21f5d0d20f5797dfbc4cf85243 upstream.
I overlooked the svc->sched_data usage from schedulers when the services were converted to RCU in 3.10. Now the rare ipvsadm -E command can change the scheduler but due to the reverse order of ip_vs_bind_scheduler and ip_vs_unbind_scheduler we provide new sched_data to the old scheduler resulting in a crash.
To fix it without changing the scheduler methods we have to use synchronize_rcu() only for the editing case. It means all svc->scheduler readers should expect a NULL value. To avoid breakage for the service listing and ipvsadm -R we can use the "none" name to indicate that scheduler is not assigned, a state when we drop new connections.
--- net/netfilter/ipvs/ip_vs_core.c | 16 +++++++- net/netfilter/ipvs/ip_vs_ctl.c | 78 ++++++++++++++++++++++++--------------- net/netfilter/ipvs/ip_vs_sched.c | 12 +++--- 3 files changed, 69 insertions(+), 37 deletions(-)
net/netfilter/ipvs/ip_vs_core.c +14 -2
@@ -319,7 +319,13 @@ ip_vs_sched_persist(struct ip_vs_service* return *ignored=0 i.e. ICMP and NF_DROP */ sched =rcu_dereference (svc->scheduler); - dest = sched->schedule (svc, skb, iph); +if (sched) { +/* read svc->sched_data after svc->scheduler */ +smp_rmb (); + dest = sched->schedule (svc, skb, iph); + }else { + dest =NULL ; + }if (!dest) {IP_VS_DBG (1 ,"p-schedule: no dest found.\n" );kfree (param.pe_data);
@@ -467,7 +473,13 @@ ip_vs_schedule(struct ip_vs_service *svc } sched =rcu_dereference (svc->scheduler); - dest = sched->schedule (svc, skb, iph); +if (sched) { +/* read svc->sched_data after svc->scheduler */ +smp_rmb (); + dest = sched->schedule (svc, skb, iph); + }else { + dest =NULL ; + }if (dest ==NULL ) {IP_VS_DBG (1 ,"Schedule: no dest found.\n" );return NULL ;
net/netfilter/ipvs/ip_vs_ctl.c +49 -29
174 lines not on this page · raw message
net/netfilter/ipvs/ip_vs_sched.c +6 -6
@@ -74,7 +74,7 @@ void ip_vs_unbind_scheduler(struct ip_vsif (sched->done_service) sched->done_service (svc); -/* svc->scheduler can not be set to NULL */ +/* svc->scheduler can be set to NULL only by caller */ }
@@ -147,21 +147,21 @@ void ip_vs_scheduler_put(struct ip_vs_scvoid ip_vs_scheduler_err (struct ip_vs_service *svc,const char *msg) { -struct ip_vs_scheduler *sched; +struct ip_vs_scheduler *sched =rcu_dereference (svc->scheduler); +char *sched_name = sched ? sched->name :"none" ; - sched =rcu_dereference (svc->scheduler);if (svc->fwmark) {IP_VS_ERR_RL ("%s: FWM %u 0x%08X - %s\n" , - sched->name, svc->fwmark, svc->fwmark, msg); + sched_name, svc->fwmark, svc->fwmark, msg); #ifdef CONFIG_IP_VS_IPV6 }else if (svc->af ==AF_INET6 ) {IP_VS_ERR_RL ("%s: %s [%pI6c]:%d - %s\n" , - sched->name,ip_vs_proto_name (svc->protocol), + sched_name,ip_vs_proto_name (svc->protocol), &svc->addr.in6,ntohs (svc->port), msg);#endif }else {IP_VS_ERR_RL ("%s: %s %pI4:%d - %s\n" , - sched->name,ip_vs_proto_name (svc->protocol), + sched_name,ip_vs_proto_name (svc->protocol), &svc->addr.ip,ntohs (svc->port), msg); } }
Patches currently in stable-queue which might be from [email protected] are
queue-4.1/ipvs-call-skb_sender_cpu_clear.patch queue-4.1/ipvs-skb_orphan-in-case-of-forwarding.patch queue-4.1/ipvs-do-not-use-random-local-source-address-for-tunnels.patch queue-4.1/ipvs-fix-crash-if-scheduler-is-changed.patch queue-4.1/ipvs-fix-crash-with-sync-protocol-v0-and-ftp.patch