Skip to content

Commit 3f20efb

Browse files
arndbhorms
authored andcommitted
ipvs: handle ip_vs_fill_iph_skb_off failure
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 <arnd@arndb.de> Fixes: b0e010c ("ipvs: replace ip_vs_fill_ip4hdr with ip_vs_fill_iph_skb_off") Acked-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: Simon Horman <horms@verge.net.au>
1 parent 017b1b6 commit 3f20efb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎net/netfilter/ipvs/ip_vs_pe_sip.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ ip_vs_sip_fill_param(struct ip_vs_conn_param *p, struct sk_buff *skb)
7070
const char *dptr;
7171
int retc;
7272

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

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

0 commit comments

Comments
 (0)