include/net/ip_vs.h:1080:2: warning: 'ipvs' may be used uninitialized in this function
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): 201509011028.xcctBo3Y%[email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Julian Anastasov
maintainerHello,
Quoted 27 lines · Simon Horman
[CC Julian, lvs-dev]
Hi Alex, Hi All,
Quoted 14 lines · kbuild test robot
tree: git://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-next.git master head: 5e26b1b3abce05c177feb589260031519a1bc7b1 commit: 5e26b1b3abce05c177feb589260031519a1bc7b1 [14/14] ipvs: support scheduling inverse and icmp SCTP packets config: x86_64-randconfig-x001-201535 (attached as .config) reproduce: git checkout 5e26b1b3abce05c177feb589260031519a1bc7b1 # save the attached .config to linux build tree make ARCH=x86_64Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_WarningsAll warnings (new ones prefixed by >>):
Quoted 7 lines
In file included from
net/netfilter/ipvs/ip_vs_proto_sctp.c:9:0:
net/netfilter/ipvs/ip_vs_proto_sctp.c: In function 'sctp_conn_schedule':Quoted 1 line
Quoted 1 line
include/net/ip_vs.h:1080:2: warning: 'ipvs' may be used uninitialized in this function [-Wmaybe-uninitialized]return ipvs->sysctl_sloppy_sctp; ^ net/netfilter/ipvs/ip_vs_proto_sctp.c:18:21: note: 'ipvs' was declared here struct netns_ipvs *ipvs;
Quoted 6 lines
I wonder if squashing the following into the commit noted above is a good way to resolve this problem.
It looks to me that 'ipvs' may indeed be initialised. But that may be resolved by simply initialising it before rather than after the call to
sctp_conn_schedule()in question.
My compiler is silent about this problem :(
It needs to be fixed...
Quoted 1 line
My main concern is that
rcu_read_lock()may also need to move.
Not needed.
Quoted 18 lines
net/netfilter/ipvs/ip_vs_proto_sctp.c +2
-2@@ -13,9 +13,9 @@ sctp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd, int *verdict, struct ip_vs_conn **cpp, struct ip_vs_iphdr *iph) { - struct net *net; + struct net *net = skb_net(skb); +struct netns_ipvs *ipvs =net_ipvs (net);struct ip_vs_service *svc; -struct netns_ipvs *ipvs;sctp_chunkhdr_t _schunkh, *sch;sctp_sctphdr_t *sh, _sctph;__be16 _ports[2 ], *ports =NULL ;
net/netfilter/ipvs/ip_vs_proto_sctp.c sctp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd, · line 45
Quoted 8 lines
net/netfilter/ipvs/ip_vs_proto_sctp.c +0
-2@@ -40,8 +40,6 @@ sctp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,return 0 ; } - net =skb_net (skb); - ipvs =net_ipvs (net);rcu_read_lock ();if (likely (!ip_vs_iph_inverse (iph))) svc = ip_vs_service_find(net, af, skb->mark, iph->protocol,
Such patch looks good to me.
Regards
--
Julian Anastasov <[email protected]>
Quoted 39 lines · Julian Anastasov
Hello,
Quoted 27 lines · Simon Horman
[CC Julian, lvs-dev]
Hi Alex, Hi All,
Quoted 14 lines · kbuild test robot
tree: git://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-next.git master head: 5e26b1b3abce05c177feb589260031519a1bc7b1 commit: 5e26b1b3abce05c177feb589260031519a1bc7b1 [14/14] ipvs: support scheduling inverse and icmp SCTP packets config: x86_64-randconfig-x001-201535 (attached as .config) reproduce: git checkout 5e26b1b3abce05c177feb589260031519a1bc7b1 # save the attached .config to linux build tree make ARCH=x86_64Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_WarningsAll warnings (new ones prefixed by >>):
Quoted 7 lines
In file included from
net/netfilter/ipvs/ip_vs_proto_sctp.c:9:0:
net/netfilter/ipvs/ip_vs_proto_sctp.c: In function 'sctp_conn_schedule':Quoted 1 line
Quoted 1 line
include/net/ip_vs.h:1080:2: warning: 'ipvs' may be used uninitialized in this function [-Wmaybe-uninitialized]return ipvs->sysctl_sloppy_sctp; ^ net/netfilter/ipvs/ip_vs_proto_sctp.c:18:21: note: 'ipvs' was declared here struct netns_ipvs *ipvs;Quoted 6 lines
I wonder if squashing the following into the commit noted above is a good way to resolve this problem.
It looks to me that 'ipvs' may indeed be initialised. But that may be resolved by simply initialising it before rather than after the call to
sctp_conn_schedule()in question.
Quoted 6 lines
My compiler is silent about this problem :(It needs to be fixed...
Quoted 1 line
My main concern is that
rcu_read_lock()may also need to move.Not needed.
Thanks for confirming that.
I have squashed my change into Alex's patch and pushed the result. For reference it is as follows:
From: Alex Gartrell <[email protected]>
Subject: [PATCH] ipvs: support scheduling inverse and icmp SCTP packets
In the event of an icmp packet, take only the ports instead of trying to grab the full header.
In the event of an inverse packet, use the source address and port.
--- net/netfilter/ipvs/ip_vs_proto_sctp.c | 46 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-)
net/netfilter/ipvs/ip_vs_proto_sctp.c +25 -21
@@ -13,37 +13,41 @@ sctp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd, int *verdict, struct ip_vs_conn **cpp, struct ip_vs_iphdr *iph) { - struct net *net; + struct net *net = skb_net(skb); +struct netns_ipvs *ipvs =net_ipvs (net);struct ip_vs_service *svc; -struct netns_ipvs *ipvs;sctp_chunkhdr_t _schunkh, *sch;sctp_sctphdr_t *sh, _sctph; - -if (ip_vs_iph_icmp (iph)) { -/* TEMPORARY - do not schedule icmp yet */ - *verdict =NF_ACCEPT ; -return 0 ; - } - - sh =skb_header_pointer (skb, iph->len,sizeof (_sctph), &_sctph); -if (sh ==NULL ) { - *verdict =NF_DROP ; -return 0 ; +__be16 _ports[2 ], *ports =NULL ; + +if (likely (!ip_vs_iph_icmp (iph))) { + sh =skb_header_pointer (skb, iph->len,sizeof (_sctph), &_sctph); +if (sh) { + sch =skb_header_pointer ( + skb, iph->len +sizeof (sctp_sctphdr_t), +sizeof (_schunkh), &_schunkh); +if (sch && (sch->type ==SCTP_CID_INIT || +sysctl_sloppy_sctp (ipvs))) + ports = &sh->source; + } + }else { + ports =skb_header_pointer ( + skb, iph->len,sizeof (_ports), &_ports); } - sch =skb_header_pointer (skb, iph->len +sizeof (sctp_sctphdr_t), -sizeof (_schunkh), &_schunkh); -if (sch ==NULL ) { +if (!ports) { *verdict =NF_DROP ;return 0 ; } - net =skb_net (skb); - ipvs =net_ipvs (net);rcu_read_lock (); -if ((sch->type ==SCTP_CID_INIT ||sysctl_sloppy_sctp (ipvs)) && - (svc =ip_vs_service_find (net, af, skb->mark, iph->protocol, - &iph->daddr, sh->dest))) { +if (likely (!ip_vs_iph_inverse (iph))) + svc =ip_vs_service_find (net, af, skb->mark, iph->protocol, + &iph->daddr, ports[1 ]); +else + svc =ip_vs_service_find (net, af, skb->mark, iph->protocol, + &iph->saddr, ports[0 ]); +if (svc) {int ignored;if (ip_vs_todrop (ipvs)) {
Signature · 1 line
2.1.4
Julian Anastasov
maintainerHello,
Quoted 24 lines · Simon Horman
I have squashed my change into Alex's patch and pushed the result. For reference it is as follows:
From: Alex Gartrell <[email protected]>
Subject: [PATCH] ipvs: support scheduling inverse and icmp SCTP packetsIn the event of an icmp packet, take only the ports instead of trying to grab the full header.
In the event of an inverse packet, use the source address and port.
Signed-off-by Alex Gartrell <[email protected]>Acked-by Julian Anastasov <[email protected]>[horms: initialise 'ipvs' before it is used]Signed-off-by Simon Horman <[email protected]>--- net/netfilter/ipvs/ip_vs_proto_sctp.c | 46 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-)net/netfilter/ipvs/ip_vs_proto_sctp.c +0
-0
net/netfilter/ipvs/ip_vs_proto_sctp.c sctp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd, · line 17
Quoted 6 lines
net/netfilter/ipvs/ip_vs_proto_sctp.c +2
-1@@ -13,37 +13,41 @@ sctp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd, int *verdict, struct ip_vs_conn **cpp, struct ip_vs_iphdr *iph) { - struct net *net; + struct net *net = skb_net(skb); +struct netns_ipvs *ipvs =net_ipvs (net);
Looks good, thanks!
Quoted 46 lines
net/netfilter/ipvs/ip_vs_proto_sctp.c +16
-20struct ip_vs_service *svc; -struct netns_ipvs *ipvs;sctp_chunkhdr_t _schunkh, *sch;sctp_sctphdr_t *sh, _sctph; - -if (ip_vs_iph_icmp (iph)) { -/* TEMPORARY - do not schedule icmp yet */ - *verdict =NF_ACCEPT ; -return 0 ; - } - - sh =skb_header_pointer (skb, iph->len,sizeof (_sctph), &_sctph); -if (sh ==NULL ) { - *verdict =NF_DROP ; -return 0 ; +__be16 _ports[2 ], *ports =NULL ; + +if (likely (!ip_vs_iph_icmp (iph))) { + sh =skb_header_pointer (skb, iph->len,sizeof (_sctph), &_sctph); +if (sh) { + sch =skb_header_pointer ( + skb, iph->len +sizeof (sctp_sctphdr_t), +sizeof (_schunkh), &_schunkh); +if (sch && (sch->type ==SCTP_CID_INIT || +sysctl_sloppy_sctp (ipvs))) + ports = &sh->source; + } + }else { + ports =skb_header_pointer ( + skb, iph->len,sizeof (_ports), &_ports); } - sch =skb_header_pointer (skb, iph->len +sizeof (sctp_sctphdr_t), -sizeof (_schunkh), &_schunkh); -if (sch ==NULL ) { +if (!ports) { *verdict =NF_DROP ;return 0 ; } - net =skb_net (skb); - ipvs =net_ipvs (net);rcu_read_lock (); -if ((sch->type ==SCTP_CID_INIT ||sysctl_sloppy_sctp (ipvs)) && - (svc =ip_vs_service_find (net, af, skb->mark, iph->protocol, - &iph->daddr, sh->dest))) {
net/netfilter/ipvs/ip_vs_proto_sctp.c sctp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd, · line 53
Quoted 10 lines
net/netfilter/ipvs/ip_vs_proto_sctp.c +7
-0+if (likely (!ip_vs_iph_inverse (iph))) + svc =ip_vs_service_find (net, af, skb->mark, iph->protocol, + &iph->daddr, ports[1 ]); +else + svc =ip_vs_service_find (net, af, skb->mark, iph->protocol, + &iph->saddr, ports[0 ]); +if (svc) {int ignored;if (ip_vs_todrop (ipvs)) {
Regards
--
Julian Anastasov <[email protected]>