Received: by 10.192.165.156 with SMTP id m28csp34461imm; Tue, 10 Apr 2018 15:50:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/FW2/Wc13AZovMiC0II3iD9fQ0lmaq9TBYnYQJj6MdgcVpIw5LC9oCHpCy4KwGFX9SFX97 X-Received: by 2002:a17:902:6909:: with SMTP id j9-v6mr2368088plk.92.1523400631508; Tue, 10 Apr 2018 15:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523400631; cv=none; d=google.com; s=arc-20160816; b=NO1YW47xEszvSdbh98mpw+21cAMQQq8cfjPUw/rRJDg1vWbbrNvYJRvEY7F65dP8Sp o4Mmjmo3kDfxNaBegWLJo2n6iMca7hsToMu4SD9SOMxKW6Xb++oKYHYTP9ZKa1qkgUzS z7dTPxkuv5DvVHyKVMGPcaAb80m0Q63OuOic/MnnCfBAkfVudpEX3E+BTS3G/J9xwm9A uPKjvP1c5czduWpBI9ZRZOw5vfRcMYsNg4o6bWCslD/SOdCX4Gg28m2+gskahcgK5sQf IuzDE+lxikYts+oTgt2AmbunvuCDh6v7MggypB5tBvBg5ghRjaYwpFUCD+Vs59QHvVzp b5CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=bSwexh5GL0BoZompddBnnAULm+bu0VS5VbZbgTEgsyc=; b=eoAI6DVVSAkGJVpYSofQRKBkokYiK3+et3gQDfrFAzH6Si6gNQAoK0Sw4FaiqvON9K +KppcJzURNfzc6DmNke1QNirkaFwMyGGhMNzNACdErihrqtay9GuiYVfgV53AZA91EOE 52y8fHknZmGVejItSNzwp4lKhCUCZUuam3XbTc5VfLIbJGhvBCnfo1n3krGZOI6YlrYN FXZeEicc5B35byweltV2WeE8BjT+Cla/SYqXnOUuuqRSQp3kMutULQuSF8ae1NPmpcYr KpO74eaT/G+TP0qFlt/X+4jxRxnOfGGyEY7CTAkp6XHcxt5Vrig4vuZxrLCiOK/vGID0 hFZw== ARC-Authentication-Results: i=1; mx.google.com; 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 f3si2394570pgu.783.2018.04.10.15.49.54; Tue, 10 Apr 2018 15:50:31 -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; 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 S1756139AbeDJWpA (ORCPT + 99 others); Tue, 10 Apr 2018 18:45:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45168 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932546AbeDJWjR (ORCPT ); Tue, 10 Apr 2018 18:39:17 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2E81BD61; Tue, 10 Apr 2018 22:39:16 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianbo Liu , Or Gerlitz , Roi Dayan , Saeed Mahameed Subject: [PATCH 4.14 124/138] net/mlx5e: Fix memory usage issues in offloading TC flows Date: Wed, 11 Apr 2018 00:25:14 +0200 Message-Id: <20180410212916.611431195@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jianbo Liu [ Upstream commit af1607c37d9d85a66fbcf43b7f11bf3d94b9bb69 ] For NIC flows, the parsed attributes are not freed when we exit successfully from mlx5e_configure_flower(). There is possible double free for eswitch flows. If error is returned from rhashtable_insert_fast(), the parse attrs will be freed in mlx5e_tc_del_flow(), but they will be freed again before exiting mlx5e_configure_flower(). To fix both issues we do the following: (1) change the condition that determines if to issue the free call to check if this flow is NIC flow, or it does not have encap action. (2) reorder the code such that that the check and free calls are done before we attempt to add into the hash table. Fixes: 232c001398ae ('net/mlx5e: Add support to neighbour update flow') Signed-off-by: Jianbo Liu Reviewed-by: Or Gerlitz Reviewed-by: Roi Dayan Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -2091,19 +2091,19 @@ int mlx5e_configure_flower(struct mlx5e_ if (err != -EAGAIN) flow->flags |= MLX5E_TC_FLOW_OFFLOADED; + if (!(flow->flags & MLX5E_TC_FLOW_ESWITCH) || + !(flow->esw_attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)) + kvfree(parse_attr); + err = rhashtable_insert_fast(&tc->ht, &flow->node, tc->ht_params); - if (err) - goto err_del_rule; + if (err) { + mlx5e_tc_del_flow(priv, flow); + kfree(flow); + } - if (flow->flags & MLX5E_TC_FLOW_ESWITCH && - !(flow->esw_attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)) - kvfree(parse_attr); return err; -err_del_rule: - mlx5e_tc_del_flow(priv, flow); - err_free: kvfree(parse_attr); kfree(flow);