Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2025486imu; Fri, 14 Dec 2018 04:42:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vpsq66+piXiWckqMkCyQ7rDPV/ggzFJu/bnPvn/ackliQyEfzOENA+AkErJ6YLysZz4IZQ X-Received: by 2002:a17:902:9a9:: with SMTP id 38mr2704823pln.204.1544791345837; Fri, 14 Dec 2018 04:42:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544791345; cv=none; d=google.com; s=arc-20160816; b=WvcPgZkapkBrnC6Hnu/iE89dHhL5QeXf/pJ+zRQouQD85zzpvlSp9h35erHgsfRhfU ffuQep1Xjxo2UxwOUDvO8E+2Ivqklm7FhHTv8OMg9wS1GiFsyILcc4tVCaNeojEucTm/ xfbcAX3pvfQTNPngHX1Uf3FyiDhn/bZ25gZWyQl6AiNwTQt/PS+QS3LSmZCmWlXV+YOr phmBAt4WjtdB04FfHcVv2874maSlpMdniR1Yos8JtMYqu826tvrKiN7hIKx7OIf9r7k+ tcPaN4PlZCGLe1FWqOdyO6DjwLp34+gDOsJJDMPaK6zBFOy24ViVHY3ptKBXelxCnczz E/UA== 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=pq20rj1saT/fhWtYx3p2dsz4S++orxTi0FeP3r2YOOQ=; b=V8hrGs1Gs+dWE84R9F5vs0kSU29pk4VqN/DzXEddeYmEFUnp0l9zc28T7IjhiH3iZk 1ck73ov9rAXTQAe02xLtw+Xzy/7Q9RkZwqoT/Wk49yvjOERMpZCpT7FMGvHTTyJ5nn4O SI9pTAFxZTi8vBeGGYkg0BD/teW4yn9s1jhlxxmOGlQuztWjmQkCy34gXUe9QErCAuv+ ls06K0pwFp3d/+Wxjnz5s50L2xlxMzCKe9Mi07CRaEm3AOcrWvz2IkJgBmh9f6wsldy8 6zEB5Mlkqh2TIbT0+Q1S0i8ZJQ5YQCsS6PLRa6x4mlLx2YUboGw6m6VHP4Pctg6sj86A pz+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="LshzqQ/0"; 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 20si4068278pft.177.2018.12.14.04.42.10; Fri, 14 Dec 2018 04:42:25 -0800 (PST) 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="LshzqQ/0"; 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 S1729540AbeLNMDg (ORCPT + 99 others); Fri, 14 Dec 2018 07:03:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:47348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729775AbeLNMDc (ORCPT ); Fri, 14 Dec 2018 07:03:32 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 477832145D; Fri, 14 Dec 2018 12:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789011; bh=002hMrZurczKj3y/JFpzaLPtg9lCanElWKs4UWAGA7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LshzqQ/0jdSDEXbe+K3iym7FPHJ4x41rWnDGSjIDOup2cVihPRsBCMLBeWMXmO/XV TSwznrPGyzkrF/t3Ea/qeEpZgXwm8bPzb+tVwXz0CaFRlXH35F3xvW82pvjtZxtW2K Of+/1ZlctN9Yx1/ljMikYmSuXQnORn98qNycYbXA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.19 060/142] netfilter: xt_hashlimit: fix a possible memory leak in htable_create() Date: Fri, 14 Dec 2018 12:59:05 +0100 Message-Id: <20181214115749.458157458@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115747.053633987@linuxfoundation.org> References: <20181214115747.053633987@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit b4e955e9f372035361fbc6f07b21fe2cc6a5be4a ] In the htable_create(), hinfo is allocated by vmalloc() So that if error occurred, hinfo should be freed. Fixes: 11d5f15723c9 ("netfilter: xt_hashlimit: Create revision 2 to support higher pps rates") Signed-off-by: Taehee Yoo Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/xt_hashlimit.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 3e7d259e5d8d..1ad4017f9b73 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -295,9 +295,10 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg, /* copy match config into hashtable config */ ret = cfg_copy(&hinfo->cfg, (void *)cfg, 3); - - if (ret) + if (ret) { + vfree(hinfo); return ret; + } hinfo->cfg.size = size; if (hinfo->cfg.max == 0) @@ -814,7 +815,6 @@ hashlimit_mt_v1(const struct sk_buff *skb, struct xt_action_param *par) int ret; ret = cfg_copy(&cfg, (void *)&info->cfg, 1); - if (ret) return ret; @@ -830,7 +830,6 @@ hashlimit_mt_v2(const struct sk_buff *skb, struct xt_action_param *par) int ret; ret = cfg_copy(&cfg, (void *)&info->cfg, 2); - if (ret) return ret; @@ -921,7 +920,6 @@ static int hashlimit_mt_check_v1(const struct xt_mtchk_param *par) return ret; ret = cfg_copy(&cfg, (void *)&info->cfg, 1); - if (ret) return ret; @@ -940,7 +938,6 @@ static int hashlimit_mt_check_v2(const struct xt_mtchk_param *par) return ret; ret = cfg_copy(&cfg, (void *)&info->cfg, 2); - if (ret) return ret; -- 2.19.1