Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1540842pxb; Thu, 16 Sep 2021 09:32:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/tM9OaiGnd6jo2mMk/lhwOVziGC4WNyzTjmbfUHpOOVvRAmMRSOFYg/edb1ZaC84GofnU X-Received: by 2002:a5e:c70c:: with SMTP id f12mr5111753iop.166.1631809939437; Thu, 16 Sep 2021 09:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631809939; cv=none; d=google.com; s=arc-20160816; b=zXH+u4mKuwLfsAeO34RQ3R052Ry7kBBClDHNlGBk/gkxTlOmwuguGJIkfHNfP23ws0 WAbnVIauTq35mB2hVaLNkQbqBJb+LjvZPWoOBuT8VP42vbo6YR2rUuqmmut/fRI560pN T3Yb3EZokVNWndh+HG0virJPhlovQ8pgGqgsAnmvYpCYJ2O/ThUNs0GlmI3gStdVZoir 6wl2T98TCnR03dCCCD5Jw2yv35E4eP0lKFof2qm+c5KiqJj7FlMKAakb+78Kso1ioFYU 7vI2RF50hlESs6qjOYlm4iQi9m4yYOKJYy2mq7oH0NTGytOC8xrigM8KftqR6AdcSgbL TDig== 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=aCwN70FPr/SxH2oo0wxZklP3MkkPUzR6zDlylipE82g=; b=gV32akG8AyTIaV3s3UHWKMzUR25KUwH6p2h387B3OwqsAzJooOUGHcUrVmpQCtf5du PQsk2YV2f+JGirjblbohFH+E8ZmqOZjY5t/YX9XXh1Oacq/m8xqaWPzR5UpvHy9m9DZy TGKLbAg3TjlDzrqVQHdCU8OtEuBR9hodlXUQGfYsTjq43MB9cBRv7jtBEnATFXrK21dX 8Ys4JcF44yLkEZLZuwHdX5bSpHAoj3Lxqm5cF3Wwp6EtPDoRIKReyE2Sk9pLH6p7guJG 5OGM6R8fjpC2jPiOl3d10mNnTMLa0mnL9DWdxwLK4WzavraxAk/MLfdzhw0lG0Wc23j2 /Zgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MR86ZyDH; 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 m1si2953526ila.78.2021.09.16.09.32.07; Thu, 16 Sep 2021 09:32:19 -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=MR86ZyDH; 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 S241085AbhIPQa0 (ORCPT + 99 others); Thu, 16 Sep 2021 12:30:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:59314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241604AbhIPQVu (ORCPT ); Thu, 16 Sep 2021 12:21:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8575F61452; Thu, 16 Sep 2021 16:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808910; bh=AzYyWIvTFUu7ICwG/e78kzaZiT+m17+3Ake8DT55j8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MR86ZyDHxmD+t8z54MYPSymFw6QjcIZCi/jsw4Ipomr2YPwiZfd2/ULTwBwl7wIhs LxRLKeJ+CaO0jBPbQheujU7GF6WlFmDiv+AtJUCL+REbbIY1FwbOwy6wJYnBaEKZpD LAS5vaH3E3xMBk2t/iDwNi3aEzgWNjCF5n22H6R8= 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.10 267/306] net/mlx5: DR, fix a potential use-after-free bug Date: Thu, 16 Sep 2021 18:00:12 +0200 Message-Id: <20210916155803.177798682@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 b3c9dc032026..478de5ded7c2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c @@ -824,9 +824,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