summaryrefslogtreecommitdiffstats
path: root/net/key
diff options
context:
space:
mode:
authorJeremy Sowden <jeremy@azazel.net>2019-05-25 19:09:35 +0100
committerSteffen Klassert <steffen.klassert@secunet.com>2019-05-28 09:20:52 +0200
commit7c80eb1c7e2b8420477fbc998971d62a648035d9 (patch)
treecfb13539258bde158acd4224ffa47aa482bbf3d7 /net/key
parentb38ff4075a80b4da5cb2202d7965332ca0efb213 (diff)
downloadlinux-stable-7c80eb1c7e2b8420477fbc998971d62a648035d9.tar.gz
linux-stable-7c80eb1c7e2b8420477fbc998971d62a648035d9.tar.bz2
linux-stable-7c80eb1c7e2b8420477fbc998971d62a648035d9.zip
af_key: fix leaks in key_pol_get_resp and dump_sp.
In both functions, if pfkey_xfrm_policy2msg failed we leaked the newly allocated sk_buff. Free it on error. Fixes: 55569ce256ce ("Fix conversion between IPSEC_MODE_xxx and XFRM_MODE_xxx.") Reported-by: syzbot+4f0529365f7f2208d9f0@syzkaller.appspotmail.com Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/key')
-rw-r--r--net/key/af_key.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 4af1e1d60b9f..51c0f10bb131 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2442,8 +2442,10 @@ static int key_pol_get_resp(struct sock *sk, struct xfrm_policy *xp, const struc
goto out;
}
err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
- if (err < 0)
+ if (err < 0) {
+ kfree_skb(out_skb);
goto out;
+ }
out_hdr = (struct sadb_msg *) out_skb->data;
out_hdr->sadb_msg_version = hdr->sadb_msg_version;
@@ -2694,8 +2696,10 @@ static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr)
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 = pfk->dump.msg_version;