Skip to content

Commit

Permalink
ipvs: handle ip_vs_fill_iph_skb_off failure
Browse files Browse the repository at this point in the history
ip_vs_fill_iph_skb_off() may not find an IP header, and gcc has
determined that ip_vs_sip_fill_param() then incorrectly accesses
the protocol fields:

net/netfilter/ipvs/ip_vs_pe_sip.c: In function 'ip_vs_sip_fill_param':
net/netfilter/ipvs/ip_vs_pe_sip.c:76:5: error: 'iph.protocol' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  if (iph.protocol != IPPROTO_UDP)
     ^
net/netfilter/ipvs/ip_vs_pe_sip.c:81:10: error: 'iph.len' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  dataoff = iph.len + sizeof(struct udphdr);
          ^

This adds a check for the ip_vs_fill_iph_skb_off() return code
before looking at the ip header data returned from it.

Signed-off-by: Arnd Bergmann <[email protected]>
Fixes: b0e010c ("ipvs: replace ip_vs_fill_ip4hdr with ip_vs_fill_iph_skb_off")
Acked-by: Julian Anastasov <[email protected]>
Signed-off-by: Simon Horman <[email protected]>
  • Loading branch information
arndb authored and horms committed Mar 7, 2016
1 parent 017b1b6 commit 3f20efb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/netfilter/ipvs/ip_vs_pe_sip.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ ip_vs_sip_fill_param(struct ip_vs_conn_param *p, struct sk_buff *skb)
const char *dptr;
int retc;

ip_vs_fill_iph_skb(p->af, skb, false, &iph);
retc = ip_vs_fill_iph_skb(p->af, skb, false, &iph);

/* Only useful with UDP */
if (iph.protocol != IPPROTO_UDP)
if (!retc || iph.protocol != IPPROTO_UDP)
return -EINVAL;
/* todo: IPv6 fragments:
* I think this only should be done for the first fragment. /HS
Expand Down

0 comments on commit 3f20efb

Please sign in to comment.