Commit 1730554f253deb65fe5112c54b2f898d5318a328
Committed by
David S. Miller
1 parent
adf044c877
Exists in
master
and in
39 other branches
ipv6: syncookies: free reqsk on xfrm_lookup error
cookie_v6_check() did not call reqsk_free() if xfrm_lookup() fails, leaking the request sock. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 11 additions and 11 deletions Side-by-side Diff
net/ipv6/syncookies.c
... | ... | @@ -199,10 +199,8 @@ |
199 | 199 | ireq6 = inet6_rsk(req); |
200 | 200 | treq = tcp_rsk(req); |
201 | 201 | |
202 | - if (security_inet_conn_request(sk, skb, req)) { | |
203 | - reqsk_free(req); | |
204 | - goto out; | |
205 | - } | |
202 | + if (security_inet_conn_request(sk, skb, req)) | |
203 | + goto out_free; | |
206 | 204 | |
207 | 205 | req->mss = mss; |
208 | 206 | ireq->rmt_port = th->source; |
209 | 207 | |
... | ... | @@ -255,14 +253,13 @@ |
255 | 253 | fl.fl_ip_dport = inet_rsk(req)->rmt_port; |
256 | 254 | fl.fl_ip_sport = inet_sk(sk)->sport; |
257 | 255 | security_req_classify_flow(req, &fl); |
258 | - if (ip6_dst_lookup(sk, &dst, &fl)) { | |
259 | - reqsk_free(req); | |
260 | - goto out; | |
261 | - } | |
256 | + if (ip6_dst_lookup(sk, &dst, &fl)) | |
257 | + goto out_free; | |
258 | + | |
262 | 259 | if (final_p) |
263 | 260 | ipv6_addr_copy(&fl.fl6_dst, final_p); |
264 | 261 | if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
265 | - goto out; | |
262 | + goto out_free; | |
266 | 263 | } |
267 | 264 | |
268 | 265 | req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); |
... | ... | @@ -273,7 +270,10 @@ |
273 | 270 | ireq->rcv_wscale = rcv_wscale; |
274 | 271 | |
275 | 272 | ret = get_cookie_sock(sk, skb, req, dst); |
276 | - | |
277 | -out: return ret; | |
273 | +out: | |
274 | + return ret; | |
275 | +out_free: | |
276 | + reqsk_free(req); | |
277 | + return NULL; | |
278 | 278 | } |