Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3819008ybi; Mon, 29 Jul 2019 13:14:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZd7BZOptbo5ChDjZSAGQcDKvRSasp+rh5jn8Z7H6fWDWW+wbDYJY51rBotWyiGIw9Becz X-Received: by 2002:a65:52c5:: with SMTP id z5mr91806312pgp.118.1564431260156; Mon, 29 Jul 2019 13:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431260; cv=none; d=google.com; s=arc-20160816; b=caKf4DotaDZSJSP1m4K1ylhowG4j8WIxHTpjFW7ASTzwn8QUDRQdpEiw5KQRA1Y/ty Q+gGnjVgV1mkwJ8hoDB2+5Rd5V0LVd5I4RocnYDO/SvEGB+M6WjvYiUq2IWkeJ1XWTu6 J71eVFU4DIARGMmNVC4w+wK/Au0dACCkZq4iDI/jRusWVlxSLIgFazqee0PvFd33Qn1J KMy81JZylvW58pGD1cm/6BA1HO9aIC0axPyscqAhHwt6KE6tlBGhJTGwhc5qFwZB49mX cbsNSOxmrCUaRDnRM2EzuUUJFthSFggiLg9VFkNaQhnSe/56pfhmqK+joo5SibIK6bai pDsg== 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=lA7n6uUxrNH+hChoRbJP5SxYiqxU2s0xKyJc6loPhHk=; b=av2CJkuQN95bJv+ONkpYOB7AbwGB1M0C0KLB6OEkLxSZM2sii06nIug6Hm2NfkZbd9 HdJbckzKcJPvFUd1ir25ZSTQ3RLuQ5mbnPoWI6DNE1v08IGVIfItUIIzFriBbEV0SOg5 dVFNk+HpiU9UqSQKVfr5qyb719NK0GHhc579FrAabbj8BiYKiWxSICiwJghb9ZWJTkiv qJsWOwLIGgkGrrZZ7NSiaxwkr4Xer9nFgjLjb6SkNUymnC+UIwwpOv1CbVzdkl9BiWos hqWmGR43fGflkbqGPS87ATFwAcKhvx4y9NLMvSe8WrdAlbmXD+/cqkeCs/Bunw8YejV/ jn4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uYYsFaS6; 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 59si26086497plc.425.2019.07.29.13.14.04; Mon, 29 Jul 2019 13:14:20 -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=uYYsFaS6; 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 S1730543AbfG2UM7 (ORCPT + 99 others); Mon, 29 Jul 2019 16:12:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:43930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729464AbfG2TbK (ORCPT ); Mon, 29 Jul 2019 15:31:10 -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 63C30217F4; Mon, 29 Jul 2019 19:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428669; bh=WlJ4yrxopqTT3+7UsmQK1o/hzQ+WKHc5DJDQr2AXGWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uYYsFaS6xLwkEqOS7S69EISfh5nodjcLNdpjfNX/WEAiKrTBSkM3mBD4eDLh+sAXR VpFrR6Y/h687kUwzE+HVy6xUOaoU7rGpOXA+swyZczFkjKJJM7Zm9pevfdZn29gmG8 Xwu2jIKLNaRBmVg+291zWz4a/fZTAj8EWaC8O2C4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 099/293] gtp: add missing gtp_encap_disable_sock() in gtp_encap_enable() Date: Mon, 29 Jul 2019 21:19:50 +0200 Message-Id: <20190729190832.220102907@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 e30155fd23c9c141cbe7d99b786e10a83a328837 ] If an invalid role is sent from user space, gtp_encap_enable() will fail. Then, it should call gtp_encap_disable_sock() but current code doesn't. It makes memory leak. Fixes: 91ed81f9abc7 ("gtp: support SGSN-side tunnels") Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/gtp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index f38e32a7ec9c..dba3869b61be 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -845,8 +845,13 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[]) if (data[IFLA_GTP_ROLE]) { role = nla_get_u32(data[IFLA_GTP_ROLE]); - if (role > GTP_ROLE_SGSN) + if (role > GTP_ROLE_SGSN) { + if (sk0) + gtp_encap_disable_sock(sk0); + if (sk1u) + gtp_encap_disable_sock(sk1u); return -EINVAL; + } } gtp->sk0 = sk0; -- 2.20.1