Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1571979pxb; Thu, 16 Sep 2021 10:09:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI50MAt6ZZamiI7wq0dUrGJJ8b/uZ9/rCMfPfKI45Q9bU6fyGw94IcMZy4yjx+hUUmHfi3 X-Received: by 2002:a17:907:75ca:: with SMTP id jl10mr7464610ejc.302.1631812146142; Thu, 16 Sep 2021 10:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631812146; cv=none; d=google.com; s=arc-20160816; b=K4EbIj7m12/Rv7QNqkYDxdoKgO0uzkou75jgotVF9QwHS8bMI16ztyat/yAoASL1cH twlUtldIXW3jtIsrOZnG5nsTVmcV4tsaW+NlJjcMysLAh8d8Ik0AJ3ECJzuljrYwUrYX 7awS1qBy9sHrDrJ2r+uBEAtpMWho3hUN9hJ4olNMQAzUYfruYvefl54bcnAHj4LEE7rv lxF/PXiyR3dM7Ywl0UasXDnkrEQDoHIPR6fgkzvSkY5Wh+2g1JZEYncMc8TMPFU20ne5 R1lE34pRyMj4vabxVmEqBUyU7raF9mmAgrvwEOt29APDDFWlSyJiiScq7LdWOt0QqVN7 Z+bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LMmMaRX9xD72bO83MyYgKCpMARHayMbZkOutEFs3plA=; b=HUTrGK/oQ7BN7o1cZG++DjQY4/XnD7UWtOOOOrp7tcGyU5BNh8s6M4iupIyauG7HHB rQe3uXtuvCVvy1gQ+xpnBc1viWGh6moXvT+ck/Axoz89kEUfBa0VNv5qQFZao5+ysRI0 IJSohxMqSoctoa22v//O6hrjjphTSXzeE6KVDxRFbJcT3epMEvfuCy8PnibxWymhPnbn I1t7ruTvGAJcsp1Ufah46IiY3FlhGQeevIU+iLX+r7JwFtrRj+UIPrEbGlS+HDaoS4U1 wKgJynCeXYegc1t4mqdoTzLgeY1WTcoPSttNA9ZDayQ/j51kL8dJoNn8QS0wrBc6+pEc Zq7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RykfxUSi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de12si4006209edb.352.2021.09.16.10.08.37; Thu, 16 Sep 2021 10:09:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RykfxUSi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343669AbhIPRHD (ORCPT + 99 others); Thu, 16 Sep 2021 13:07:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:51642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347310AbhIPQ6p (ORCPT ); Thu, 16 Sep 2021 12:58:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8375A6138E; Thu, 16 Sep 2021 16:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809927; bh=KQitGf8LgkA60yKy0J2jv/cD9eB25l1vJw9SYw5CHR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RykfxUSinrfeNUwZrL04Ph29SUHmYvtBMsHxmFeEK5GB7t0Vj3aHFf0WvMFvZrtmI R4TJCaQtERDRf9IUlYo30HTvR/rhQ9rfT6m9Wx/2EfyUx3Vt68TDz8vPH6voQhK8Tp sHRFFIxG3KIHhvH+OrJnrEDmC3lIoc01m0t9J8vU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wentao_Liang , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.13 334/380] net/mlx5: DR, fix a potential use-after-free bug Date: Thu, 16 Sep 2021 18:01:31 +0200 Message-Id: <20210916155815.411110170@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wentao_Liang [ Upstream commit 6cc64770fb386b10a64a1fe09328396de7bb5262 ] In line 849 (#1), "mlx5dr_htbl_put(cur_htbl);" drops the reference to cur_htbl and may cause cur_htbl to be freed. However, cur_htbl is subsequently used in the next line, which may result in an use-after-free bug. Fix this by calling mlx5dr_err() before the cur_htbl is put. Signed-off-by: Wentao_Liang Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c index 43356fad53de..ffdfb5a94b14 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c @@ -846,9 +846,9 @@ dr_rule_handle_ste_branch(struct mlx5dr_rule *rule, new_htbl = dr_rule_rehash(rule, nic_rule, cur_htbl, ste_location, send_ste_list); if (!new_htbl) { - mlx5dr_htbl_put(cur_htbl); mlx5dr_err(dmn, "Failed creating rehash table, htbl-log_size: %d\n", cur_htbl->chunk_size); + mlx5dr_htbl_put(cur_htbl); } else { cur_htbl = new_htbl; } -- 2.30.2