* [v2 PATCH 0/2] ipvs: netns avoid crash at netns init
@ 2012-04-26 7:45 Hans Schillstrom
2012-04-26 7:45 ` [v2 PATCH 1/2] ipvs: null check of net->ipvs in lblc(r) shedulers Hans Schillstrom
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Hans Schillstrom @ 2012-04-26 7:45 UTC (permalink / raw)
To: horms, ja, wensong, lvs-devel, netdev, netfilter-devel
Cc: hans, Hans Schillstrom
Two simple patches that avoid crashes for no memory at netns init.
- Check return value of protocoll init.
- Null check of net-ipvs in shedulers.
Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
--
1.7.2.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [v2 PATCH 1/2] ipvs: null check of net->ipvs in lblc(r) shedulers
2012-04-26 7:45 [v2 PATCH 0/2] ipvs: netns avoid crash at netns init Hans Schillstrom
@ 2012-04-26 7:45 ` Hans Schillstrom
2012-04-26 7:45 ` [v2 PATCH 2/2] ipvs: take care of return value from protocol init_netns Hans Schillstrom
2012-04-26 8:30 ` [v2 PATCH 0/2] ipvs: netns avoid crash at netns init Julian Anastasov
2 siblings, 0 replies; 5+ messages in thread
From: Hans Schillstrom @ 2012-04-26 7:45 UTC (permalink / raw)
To: horms, ja, wensong, lvs-devel, netdev, netfilter-devel
Cc: hans, Hans Schillstrom
Avoid crash when registering shedulers after
the IPVS core initialization for netns fails. Do this by
checking for present core (net->ipvs).
Ver 2
-
Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
---
net/netfilter/ipvs/ip_vs_lblc.c | 3 +++
net/netfilter/ipvs/ip_vs_lblcr.c | 3 +++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index 222b6cb..df646cc 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -551,6 +551,9 @@ static int __net_init __ip_vs_lblc_init(struct net *net)
{
struct netns_ipvs *ipvs = net_ipvs(net);
+ if (!ipvs)
+ return -ENOENT;
+
if (!net_eq(net, &init_net)) {
ipvs->lblc_ctl_table = kmemdup(vs_vars_table,
sizeof(vs_vars_table),
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index 30c476f..570e31e 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -745,6 +745,9 @@ static int __net_init __ip_vs_lblcr_init(struct net *net)
{
struct netns_ipvs *ipvs = net_ipvs(net);
+ if (!ipvs)
+ return -ENOENT;
+
if (!net_eq(net, &init_net)) {
ipvs->lblcr_ctl_table = kmemdup(vs_vars_table,
sizeof(vs_vars_table),
--
1.7.2.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [v2 PATCH 2/2] ipvs: take care of return value from protocol init_netns
2012-04-26 7:45 [v2 PATCH 0/2] ipvs: netns avoid crash at netns init Hans Schillstrom
2012-04-26 7:45 ` [v2 PATCH 1/2] ipvs: null check of net->ipvs in lblc(r) shedulers Hans Schillstrom
@ 2012-04-26 7:45 ` Hans Schillstrom
2012-04-26 8:30 ` [v2 PATCH 0/2] ipvs: netns avoid crash at netns init Julian Anastasov
2 siblings, 0 replies; 5+ messages in thread
From: Hans Schillstrom @ 2012-04-26 7:45 UTC (permalink / raw)
To: horms, ja, wensong, lvs-devel, netdev, netfilter-devel
Cc: hans, Hans Schillstrom
ip_vs_create_timeout_table() can return NULL
All functions protocol init_netns is affected of this patch.
Ver 2
unlink pd before free.
Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
---
include/net/ip_vs.h | 2 +-
net/netfilter/ipvs/ip_vs_proto.c | 11 +++++++++--
net/netfilter/ipvs/ip_vs_proto_sctp.c | 5 ++++-
net/netfilter/ipvs/ip_vs_proto_tcp.c | 5 ++++-
net/netfilter/ipvs/ip_vs_proto_udp.c | 5 ++++-
5 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 990216d..f967395 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -392,7 +392,7 @@ struct ip_vs_protocol {
void (*exit)(struct ip_vs_protocol *pp);
- void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
+ int (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd);
diff --git a/net/netfilter/ipvs/ip_vs_proto.c b/net/netfilter/ipvs/ip_vs_proto.c
index 6a8d176..4238be9 100644
--- a/net/netfilter/ipvs/ip_vs_proto.c
+++ b/net/netfilter/ipvs/ip_vs_proto.c
@@ -78,8 +78,15 @@ register_ip_vs_proto_netns(struct net *net, struct ip_vs_protocol *pp)
ipvs->proto_data_table[hash] = pd;
atomic_set(&pd->appcnt, 0); /* Init app counter */
- if (pp->init_netns != NULL)
- pp->init_netns(net, pd);
+ if (pp->init_netns != NULL) {
+ int ret = pp->init_netns(net, pd);
+ if (ret) {
+ /* unlink an free proto data */
+ ipvs->proto_data_table[hash] = pd->next;
+ kfree(pd);
+ return ret;
+ }
+ }
return 0;
}
diff --git a/net/netfilter/ipvs/ip_vs_proto_sctp.c b/net/netfilter/ipvs/ip_vs_proto_sctp.c
index 1fbf7a2..9f3fb75 100644
--- a/net/netfilter/ipvs/ip_vs_proto_sctp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_sctp.c
@@ -1090,7 +1090,7 @@ out:
* timeouts is netns related now.
* ---------------------------------------------
*/
-static void __ip_vs_sctp_init(struct net *net, struct ip_vs_proto_data *pd)
+static int __ip_vs_sctp_init(struct net *net, struct ip_vs_proto_data *pd)
{
struct netns_ipvs *ipvs = net_ipvs(net);
@@ -1098,6 +1098,9 @@ static void __ip_vs_sctp_init(struct net *net, struct ip_vs_proto_data *pd)
spin_lock_init(&ipvs->sctp_app_lock);
pd->timeout_table = ip_vs_create_timeout_table((int *)sctp_timeouts,
sizeof(sctp_timeouts));
+ if (!pd->timeout_table)
+ return -ENOMEM;
+ return 0;
}
static void __ip_vs_sctp_exit(struct net *net, struct ip_vs_proto_data *pd)
diff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c b/net/netfilter/ipvs/ip_vs_proto_tcp.c
index ef8641f..cd609cc 100644
--- a/net/netfilter/ipvs/ip_vs_proto_tcp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c
@@ -677,7 +677,7 @@ void ip_vs_tcp_conn_listen(struct net *net, struct ip_vs_conn *cp)
* timeouts is netns related now.
* ---------------------------------------------
*/
-static void __ip_vs_tcp_init(struct net *net, struct ip_vs_proto_data *pd)
+static int __ip_vs_tcp_init(struct net *net, struct ip_vs_proto_data *pd)
{
struct netns_ipvs *ipvs = net_ipvs(net);
@@ -685,7 +685,10 @@ static void __ip_vs_tcp_init(struct net *net, struct ip_vs_proto_data *pd)
spin_lock_init(&ipvs->tcp_app_lock);
pd->timeout_table = ip_vs_create_timeout_table((int *)tcp_timeouts,
sizeof(tcp_timeouts));
+ if (!pd->timeout_table)
+ return -ENOMEM;
pd->tcp_state_table = tcp_states;
+ return 0;
}
static void __ip_vs_tcp_exit(struct net *net, struct ip_vs_proto_data *pd)
diff --git a/net/netfilter/ipvs/ip_vs_proto_udp.c b/net/netfilter/ipvs/ip_vs_proto_udp.c
index f4b7262..2fedb2d 100644
--- a/net/netfilter/ipvs/ip_vs_proto_udp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_udp.c
@@ -467,7 +467,7 @@ udp_state_transition(struct ip_vs_conn *cp, int direction,
cp->timeout = pd->timeout_table[IP_VS_UDP_S_NORMAL];
}
-static void __udp_init(struct net *net, struct ip_vs_proto_data *pd)
+static int __udp_init(struct net *net, struct ip_vs_proto_data *pd)
{
struct netns_ipvs *ipvs = net_ipvs(net);
@@ -475,6 +475,9 @@ static void __udp_init(struct net *net, struct ip_vs_proto_data *pd)
spin_lock_init(&ipvs->udp_app_lock);
pd->timeout_table = ip_vs_create_timeout_table((int *)udp_timeouts,
sizeof(udp_timeouts));
+ if (!pd->timeout_table)
+ return -ENOMEM;
+ return 0;
}
static void __udp_exit(struct net *net, struct ip_vs_proto_data *pd)
--
1.7.2.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [v2 PATCH 0/2] ipvs: netns avoid crash at netns init
2012-04-26 7:45 [v2 PATCH 0/2] ipvs: netns avoid crash at netns init Hans Schillstrom
2012-04-26 7:45 ` [v2 PATCH 1/2] ipvs: null check of net->ipvs in lblc(r) shedulers Hans Schillstrom
2012-04-26 7:45 ` [v2 PATCH 2/2] ipvs: take care of return value from protocol init_netns Hans Schillstrom
@ 2012-04-26 8:30 ` Julian Anastasov
2012-04-26 8:57 ` Simon Horman
2 siblings, 1 reply; 5+ messages in thread
From: Julian Anastasov @ 2012-04-26 8:30 UTC (permalink / raw)
To: Hans Schillstrom; +Cc: horms, wensong, lvs-devel, netdev, netfilter-devel, hans
Hello,
On Thu, 26 Apr 2012, Hans Schillstrom wrote:
> Two simple patches that avoid crashes for no memory at netns init.
>
> - Check return value of protocoll init.
> - Null check of net-ipvs in shedulers.
>
>
> Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
Both patches look ok
Acked-by: Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [v2 PATCH 0/2] ipvs: netns avoid crash at netns init
2012-04-26 8:30 ` [v2 PATCH 0/2] ipvs: netns avoid crash at netns init Julian Anastasov
@ 2012-04-26 8:57 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2012-04-26 8:57 UTC (permalink / raw)
To: Julian Anastasov
Cc: Hans Schillstrom, wensong, lvs-devel, netdev, netfilter-devel,
hans
On Thu, Apr 26, 2012 at 11:30:00AM +0300, Julian Anastasov wrote:
>
> Hello,
>
> On Thu, 26 Apr 2012, Hans Schillstrom wrote:
>
> > Two simple patches that avoid crashes for no memory at netns init.
> >
> > - Check return value of protocoll init.
> > - Null check of net-ipvs in shedulers.
> >
> >
> > Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
>
> Both patches look ok
>
> Acked-by: Julian Anastasov <ja@ssi.bg>
Thanks, applied to ipvs.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-04-26 8:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-26 7:45 [v2 PATCH 0/2] ipvs: netns avoid crash at netns init Hans Schillstrom
2012-04-26 7:45 ` [v2 PATCH 1/2] ipvs: null check of net->ipvs in lblc(r) shedulers Hans Schillstrom
2012-04-26 7:45 ` [v2 PATCH 2/2] ipvs: take care of return value from protocol init_netns Hans Schillstrom
2012-04-26 8:30 ` [v2 PATCH 0/2] ipvs: netns avoid crash at netns init Julian Anastasov
2012-04-26 8:57 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).