Skip to contentSkip to conversation

Don't leak sysctl tables if the scheduler registration fails

PATCH Applied Pavel Emelyanov 3 participants 3 messages Dec 3, 2007 – Dec 4, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't leak sysctl tables if the scheduler registration fails

In case we load lblc or lblcr module we can leak some sysctl tables if the call to register_ip_vs_scheduler() fails.

I've looked at the register_ip_vs_scheduler() code and saw, that the only reason to fail is the name collision, so I think that with some 3rd party schedulers this becomes a relevant issue. No?

---

net/ipv4/ipvs/ip_vs_lblc.c +6 -1
index b843a11..ad89644 100644
@@ -580,9 +580,14 @@ static struct ip_vs_scheduler ip_vs_lblc_scheduler =
 
 static int __init ip_vs_lblc_init(void)
 {
+	int ret;
+
 	INIT_LIST_HEAD(&ip_vs_lblc_scheduler.n_list);
 	sysctl_header = register_sysctl_table(lblc_root_table);
-	return register_ip_vs_scheduler(&ip_vs_lblc_scheduler);
+	ret = register_ip_vs_scheduler(&ip_vs_lblc_scheduler);
+	if (ret)
+		unregister_sysctl_table(sysctl_header);
+	return ret;
 }
 
 
net/ipv4/ipvs/ip_vs_lblcr.c +6 -1
index e5b323a..2a5ed85 100644
@@ -769,9 +769,14 @@ static struct ip_vs_scheduler ip_vs_lblcr_scheduler =
 
 static int __init ip_vs_lblcr_init(void)
 {
+	int ret;
+
 	INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list);
 	sysctl_header = register_sysctl_table(lblcr_root_table);
-	return register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
+	ret = register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
+	if (ret)
+		unregister_sysctl_table(sysctl_header);
+	return ret;
 }
 
 
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Pavel Emelyanov

In case we load lblc or lblcr module we can leak some sysctl tables if the call to register_ip_vs_scheduler() fails.

This looks correct to me.

Quoted 3 lines

I've looked at the register_ip_vs_scheduler() code and saw, that the only reason to fail is the name collision, so I think that with some 3rd party schedulers this becomes a relevant issue. No?

I guess so. Though presumably register_ip_vs_scheduler() could have other modes of failure in the future.

Quoted 1 line
Quoted 42 lines

---

net/ipv4/ipvs/ip_vs_lblc.c +6 -1
index b843a11..ad89644 100644
@@ -580,9 +580,14 @@ static struct ip_vs_scheduler ip_vs_lblc_scheduler =
 
 static int __init ip_vs_lblc_init(void)
 {
+	int ret;
+
 	INIT_LIST_HEAD(&ip_vs_lblc_scheduler.n_list);
 	sysctl_header = register_sysctl_table(lblc_root_table);
-	return register_ip_vs_scheduler(&ip_vs_lblc_scheduler);
+	ret = register_ip_vs_scheduler(&ip_vs_lblc_scheduler);
+	if (ret)
+		unregister_sysctl_table(sysctl_header);
+	return ret;
 }
 
 
net/ipv4/ipvs/ip_vs_lblcr.c +6 -1
index e5b323a..2a5ed85 100644
@@ -769,9 +769,14 @@ static struct ip_vs_scheduler ip_vs_lblcr_scheduler =
 
 static int __init ip_vs_lblcr_init(void)
 {
+	int ret;
+
 	INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list);
 	sysctl_header = register_sysctl_table(lblcr_root_table);
-	return register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
+	ret = register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
+	if (ret)
+		unregister_sysctl_table(sysctl_header);
+	return ret;
 }
 
 
Signature · 1 line
Horms
maintainer Applied
#2 lore raw

From: Simon Horman <[email protected]>
Date: Tue, 4 Dec 2007 10:36:48 +0900

Quoted 10 lines · Pavel Emelyanov
Quoted 2 lines

In case we load lblc or lblcr module we can leak some sysctl tables if the call to register_ip_vs_scheduler() fails.

This looks correct to me.

Quoted 3 lines

I've looked at the register_ip_vs_scheduler() code and saw, that the only reason to fail is the name collision, so I think that with some 3rd party schedulers this becomes a relevant issue. No?

Quoted 6 lines

I guess so. Though presumably register_ip_vs_scheduler() could have other modes of failure in the future.

Quoted 1 line

Applied, thanks.