Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1978221pxb; Thu, 16 Sep 2021 22:13:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNBB2WPw3SHXibWt1HVgYfL0rF4ywGViEpXjymMetrnoNP9nrWFYNQ7DT6LFajgtpsLWFw X-Received: by 2002:a92:b301:: with SMTP id p1mr6312261ilh.10.1631855580046; Thu, 16 Sep 2021 22:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631855580; cv=none; d=google.com; s=arc-20160816; b=K5va+4aCdi1j5ggrTrNO+EqmjsBJ/iQANPVF18OFSxiSxC/REbSzdmh2l0C1Tff98o Ru/ZxiaeAPQKqKMN+abX3og+z2tC2EjHgtGRcs+/g7qbZmUZ9loSvtwNMo3AUv9WPHQK p587O08wEDi2LS8uxhWJ1fs/TvjvfBc6/KY/SNVmw7xGWpvqEeeZonR5UWssC3fwj+Ed Ltw3a05stsLJ+cqDWueKxdwvvBQT+pumQ8WaxBOAFOtbaLoN1XRz6w5r9OH99ljBEUzu GSMgvhS7jt8BPxHGSS5dRjDikJ5SEnq6W088eVe1r9Yd02qzCxgXmGhq4NfqpvBEXjjt 2qcg== 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=GsByac7k68s0ciNCTNBGCzE/P/E5XUWoCnq4SAZLoSJ1MjZZIuRP53VSSYj8GII0jJ bBAftMfNmnZNxyIfr7hCj5HXywFEed9Y1GQaRCSXPQxnfI06MIe+P8qMK1CpKVGFbBhb kHZkGOxthyQ4828ayU7gfEZ0nFk8ZKj7E4vtflY1cyeyq1cq4muwjHmBAaAczUTTmzW9 NDGW+DhcTI8PSflHSodM80KDREY0uKPzpDIRyVThyd7Pn2a8wTCTbHcWhlC8PDtyNRq1 RkPPRtCPYgR33ceDfc7dEsAPbhLsRVmb25poH9rIwSpr9pePxRsZgxedt3vbe66+SYjf yHbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UgENbITd; 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 e35si4346372jaa.106.2021.09.16.22.12.48; Thu, 16 Sep 2021 22:13:00 -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=UgENbITd; 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 S1356340AbhIPRtk (ORCPT + 99 others); Thu, 16 Sep 2021 13:49:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:57082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355391AbhIPRlZ (ORCPT ); Thu, 16 Sep 2021 13:41:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D315C6325B; Thu, 16 Sep 2021 16:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631811167; bh=KQitGf8LgkA60yKy0J2jv/cD9eB25l1vJw9SYw5CHR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UgENbITdihsNu7m0HNNLgsCLdXYKzTttMCfEIHPz2erBtHiJJAcBuz7wkcRngvlLP VeXBqNbv/KBJw6hQWAKDnyzJ1t3gONLdq7iyN8j/4G1X7GksZ5g1SE0HJYmqObmgCU jSa10z20QB5+dzMCyULoUeSqC9AKC2Rcijzny7ho= 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.14 375/432] net/mlx5: DR, fix a potential use-after-free bug Date: Thu, 16 Sep 2021 18:02:04 +0200 Message-Id: <20210916155823.524306805@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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