| From 15672fcc77a150d12a93552263fd683503dfc11a Mon Sep 17 00:00:00 2001 |
| From: Steffen Klassert <steffen.klassert@secunet.com> |
| Date: Wed, 6 Nov 2019 08:13:49 +0100 |
| Subject: [PATCH] xfrm: Fix memleak on xfrm state destroy |
| |
| commit 86c6739eda7d2a03f2db30cbee67a5fb81afa8ba upstream. |
| |
| We leak the page that we use to create skb page fragments |
| when destroying the xfrm_state. Fix this by dropping a |
| page reference if a page was assigned to the xfrm_state. |
| |
| Fixes: cac2661c53f3 ("esp4: Avoid skb_cow_data whenever possible") |
| Reported-by: JD <jdtxs00@gmail.com> |
| Reported-by: Paul Wouters <paul@nohats.ca> |
| Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c |
| index 50621d982970..eac463c6bcb0 100644 |
| --- a/net/xfrm/xfrm_state.c |
| +++ b/net/xfrm/xfrm_state.c |
| @@ -418,6 +418,8 @@ static void ___xfrm_state_destroy(struct xfrm_state *x) |
| x->type->destructor(x); |
| xfrm_put_type(x->type); |
| } |
| + if (x->xfrag.page) |
| + put_page(x->xfrag.page); |
| xfrm_dev_state_free(x); |
| security_xfrm_state_free(x); |
| xfrm_state_free(x); |
| -- |
| 2.7.4 |
| |