Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3821170ybi; Mon, 29 Jul 2019 13:16:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhShUQr3YiQHsoPuyU+6Plg/RAZbyEoLPj2R/Rotwqf+XiBAfoT/TK0BqbeRvS95LCsBq/ X-Received: by 2002:a17:90a:228b:: with SMTP id s11mr110898922pjc.23.1564431402632; Mon, 29 Jul 2019 13:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431402; cv=none; d=google.com; s=arc-20160816; b=QvS1rFF2p4K5W99VGQQJd645TpqoHmnjZuXBH1BE14wnu1lGxaUTGclVQ2FnLut1O8 lZsV/HSrM+k2T5gziiUlMVmFUDQ8meXBrHgRqKIj0bNFRVcRGVfhDsdhCZw8EiOo3SRy gYXGX8Qjqk3l1tQqtvAE1b5KsfB1CmWMl6aPBpBGa6jTKDxv+CEk3A5pi1ssOfPWAW/Y lFana4mHOTOGFzs1M2twd/w8xQYA1jukwZjX4vIH7UnRmR9o9lARrscD9Gqt9Pig3XGA bnVBWShz+6M6pkbukbsyYEY6t66O+1WwTPRPBI9VxLHX0+uwC6eDVBmFSb6LF+44ZIx6 uycw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dq2kdH/cUfte1QABy9dJdw851Sh31gWDfNXWZWTUICg=; b=t2R+/oJ5FvvYsRutzvRI/dsxi4tOPnyXWh+2r3+LIaDljeKzNKV/SfzGHDFIjC2v/i FWwytPSis9OuRP+kHdaOKgJrhynGAXtA61v7VpxIdBzAxIr3f5wrI5YoONZ/PD4jR94E CRhj4mgWu5RUg70usr3PpIDlyW4W6Gg21smOHgV2KhiFeJyeXI99Dc3GnhA1OCU+fYkY 2AhtXVmuU9BSynE7Cx0uyl8pYCl3JFTBuvEMWOelRLADXivh6GerkZwRKiazhD72wTn2 uESgIzjjsgWyaL/FX7mMBlha7Ie0BBJ9UAoGCI3FvBU6V18gtSUV6GsBxZz3xN0PBM/5 zmAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NDZu2ReA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66si27598987pld.6.2019.07.29.13.16.27; Mon, 29 Jul 2019 13:16:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NDZu2ReA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728213AbfG2T0d (ORCPT + 99 others); Mon, 29 Jul 2019 15:26:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:38940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729762AbfG2T0b (ORCPT ); Mon, 29 Jul 2019 15:26:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D8202217D6; Mon, 29 Jul 2019 19:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428390; bh=8d90N1f6X6r12t1S7fD+JCOclmrbvumpbXPSk48yZ04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NDZu2ReAq47GXKFi9C916JP6naKWrNp5Dj1VeZ/n71ryYqAsAHnAy8KkE1xYoHX3Y liY6uTX05lqax2EjdGrtNVEG4oprw7G+PgTP0hd6Hq1xAZRpz1OREiZbHhtClZYFE4 YVTIgPFuUhrjo5XfLd89K9XH79jzB8m9AqIMG8OY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+4f0529365f7f2208d9f0@syzkaller.appspotmail.com, Jeremy Sowden , Steffen Klassert , Sasha Levin Subject: [PATCH 4.14 022/293] af_key: fix leaks in key_pol_get_resp and dump_sp. Date: Mon, 29 Jul 2019 21:18:33 +0200 Message-Id: <20190729190822.702269515@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 7c80eb1c7e2b8420477fbc998971d62a648035d9 ] 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 Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/key/af_key.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/key/af_key.c b/net/key/af_key.c index b095551a5773..ac38b47e9f86 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -2438,8 +2438,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; @@ -2690,8 +2692,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; -- 2.20.1