Received: by 10.213.65.68 with SMTP id h4csp904811imn; Thu, 22 Mar 2018 11:05:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELv4EHXSEI2bkPqfUgAsHMjKD7zVJJ0UcFk3wheAWoQYjr+o9BidNurzoRdG39sd4W1I49Jc X-Received: by 2002:a17:902:690b:: with SMTP id j11-v6mr26346901plk.124.1521741921235; Thu, 22 Mar 2018 11:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521741921; cv=none; d=google.com; s=arc-20160816; b=n9kBPpgs73mw0AXun4Ty0Ie1Q4b3TQYC+dhqsEvU2Lgn+VCzEhf3HOK9l88bFqaiwx ZNGSf33gmxNATPirK/pRxLw/+qnfA3VN8sN2Ae+C6LoLZCIpB7kctaWvF54l52wvbzt5 RQ4dpkMwPkmbcV0GKJ3gsv1+OYmn+aBpPxnbZ7t1E0In7e4g4jDkAKHVJZryV4ZNbBsN 6lls0TCpflcugeW1UBe39YdWscXuBMHybAvq1A6jB5cmbK4kfmLU5cGjQdzigO3lDupK +ND+mW6Ia4ncu/1NaTGrVDePjN+lE2lSgCfezQcxWNHAvF+65MBsvx189nMvaWktMGHe rMgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=AQ+clkR117qAYMndUvmYCQ7cYsBOLvxfdL8vSdZl7Rc=; b=AckL3wFPrTaogtfLivQztrRJSLpgimu1FvhCUjLL8qUeFRI6/WdvDWt5Jp0ovdOqXE 6wbkJO1+Y0oYY30B/Q5yY6y1XU4X+0/0ksIjujjMwv2q9VGH/P/3aJaw9glIJOtTZBcF tJoNgoDGoTAcqXEjkI703CgS+zoFNY2uhYVcx1FCI45xNWBbeIVRLC5SLh5EAfyAZ7Gc Gb4gDvw4PK2i31z0bmRA+1gy6qah/9dAIySeff7IoPLTpigQ7FDgKrNG9NNpiBWqrOJw az8J5Vg/VBpOYvp8HtAoArk2UJzFweU8Fgrs/ZQ9ohvtlHE1Ed4aXpBO/ZEG10gK1qH/ 1gAg== 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 bi1-v6si4747823plb.744.2018.03.22.11.05.06; Thu, 22 Mar 2018 11:05:21 -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 S1751748AbeCVSDq (ORCPT + 99 others); Thu, 22 Mar 2018 14:03:46 -0400 Received: from gateway33.websitewelcome.com ([192.185.146.78]:16974 "EHLO gateway33.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670AbeCVSDo (ORCPT ); Thu, 22 Mar 2018 14:03:44 -0400 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 1FB4C7C952 for ; Thu, 22 Mar 2018 13:03:44 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id z4YyejPA4A3CSz4Yyev5J3; Thu, 22 Mar 2018 13:03:44 -0500 Received: from [189.145.54.187] (port=52320 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1ez4Yw-003pYO-Nf; Thu, 22 Mar 2018 13:03:42 -0500 Date: Thu, 22 Mar 2018 13:03:42 -0500 From: "Gustavo A. R. Silva" To: Ilan Tayari , Boris Pismenny , Saeed Mahameed , Matan Barak , Leon Romanovsky Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] net/mlx5/core/fpga/ipsec: Fix use-after-free Message-ID: <20180322180342.GA18505@embeddedgus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.145.54.187 X-Source-L: No X-Exim-ID: 1ez4Yw-003pYO-Nf X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.145.54.187]:52320 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 8 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org _rule_ is being freed and then dereferenced by accessing rule->ctx Fix this by copying the value returned by PTR_ERR(rule->ctx) into a local variable for its safe use after freeing _rule_ Addresses-Coverity-ID: 1466041 ("Read from pointer after free") Fixes: 05564d0ae075 ("net/mlx5: Add flow-steering commands for FPGA IPSec implementation") Signed-off-by: Gustavo A. R. Silva --- drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c index 4f15685..0f5da49 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c @@ -1061,8 +1061,9 @@ static int fpga_ipsec_fs_create_fte(struct mlx5_core_dev *dev, rule->ctx = mlx5_fpga_ipsec_fs_create_sa_ctx(dev, fte, is_egress); if (IS_ERR(rule->ctx)) { + int err = PTR_ERR(rule->ctx); kfree(rule); - return PTR_ERR(rule->ctx); + return err; } rule->fte = fte; -- 2.7.4