All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: David Miller <davem@davemloft.net>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	<netdev@vger.kernel.org>
Subject: [PATCH 10/11] af_key: Fix memory leak in key_notify_policy.
Date: Thu, 11 Jan 2018 12:37:45 +0100	[thread overview]
Message-ID: <20180111113746.28186-11-steffen.klassert@secunet.com> (raw)
In-Reply-To: <20180111113746.28186-1-steffen.klassert@secunet.com>

We leak the allocated out_skb in case
pfkey_xfrm_policy2msg() fails. Fix this
by freeing it on error.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/key/af_key.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/key/af_key.c b/net/key/af_key.c
index d40861a048fe..7e2e7188e7f4 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2202,8 +2202,10 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_ev
 		return PTR_ERR(out_skb);
 
 	err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
-	if (err < 0)
+	if (err < 0) {
+		kfree_skb(out_skb);
 		return err;
+	}
 
 	out_hdr = (struct sadb_msg *) out_skb->data;
 	out_hdr->sadb_msg_version = PF_KEY_V2;
-- 
2.14.1

  parent reply	other threads:[~2018-01-11 11:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11 11:37 pull request (net): ipsec 2018-01-11 Steffen Klassert
2018-01-11 11:37 ` [PATCH 01/11] xfrm: Forbid state updates from changing encap type Steffen Klassert
2018-01-11 11:37 ` [PATCH 02/11] xfrm: skip policies marked as dead while rehashing Steffen Klassert
2018-01-11 11:37 ` [PATCH 03/11] af_key: fix buffer overread in verify_address_len() Steffen Klassert
2018-01-11 11:37 ` [PATCH 04/11] af_key: fix buffer overread in parse_exthdrs() Steffen Klassert
2018-01-11 11:37 ` [PATCH 05/11] xfrm: fix rcu usage in xfrm_get_type_offload Steffen Klassert
2018-01-11 11:37 ` [PATCH 06/11] xfrm: Use __skb_queue_tail in xfrm_trans_queue Steffen Klassert
2018-01-11 11:37 ` [PATCH 07/11] xfrm: Return error on unknown encap_type in init_state Steffen Klassert
2018-01-11 11:37 ` [PATCH 08/11] xfrm: don't call xfrm_policy_cache_flush while holding spinlock Steffen Klassert
2018-01-11 11:37 ` [PATCH 09/11] esp: Fix GRO when the headers not fully in the linear part of the skb Steffen Klassert
2018-01-11 11:37 ` Steffen Klassert [this message]
2018-01-11 11:37 ` [PATCH 11/11] xfrm: Fix a race in the xdst pcpu cache Steffen Klassert
2018-01-12 15:33 ` pull request (net): ipsec 2018-01-11 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180111113746.28186-11-steffen.klassert@secunet.com \
    --to=steffen.klassert@secunet.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.