Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp465002pxb; Thu, 9 Sep 2021 05:12:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhGmVPrNroIv2j7tHPeQEJDLjYJlsr3YzmR67GRSVNPQ/Xt9JrLK90ucCtjnqxP9lPocfB X-Received: by 2002:a17:907:7848:: with SMTP id lb8mr3015716ejc.494.1631189523206; Thu, 09 Sep 2021 05:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631189523; cv=none; d=google.com; s=arc-20160816; b=aXWDOggn+ItmY1ZbVaomVCphjTjQ7eEvOk1wZsESybzH90bk9jF0pLw/3nmzW0rAzH nghzTA6n79Tj19EK8YMfv1jJPuDAkGv5qPjgWd8STrIxlfk2jOf1RUBqVdgY7y5SW4gq iCIcc2mwa1r6NBJI8jS6nvady5Lus47m2HPFSZYppsvR9g0YALG6wS8eOAdopDFg8zHh RCxriqOxu3EFBHvtUsjOwRlgO0uD8Q/LHa0E8qaIZHGhGdfTgx3DSNll0xS9gVLRZRSD /46XacoSthRH0PNvXk8CYbqXxvN2HNs2qawJhU0UuOeSGjMa+Ya0WQboEDjJA7Jx92sE tsvw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LMmMaRX9xD72bO83MyYgKCpMARHayMbZkOutEFs3plA=; b=A+4vtV5O2HXeuIs9i/UbZ7uKfataW5ESnIqMZ6gwVqMljeC+zkhICz/CN9GvY/4pQX 5Q3Jz2j/lI2NOoFSohoSLOTFEc5kh1Z2k/sgiXihCfkB+aLxRlMIlHq8lOSDGO6IUJL8 5yJg3qBCPdB0BgdvtSqUta3BKnSIZFpfa0OGTrLHmBlBp6kkrQ+AKxMX5rKKGfLobDYy xHHX8RxJKASlcv451BaMv24db4W+AJstJyAusH6vmO9THlVB/AUOq/hCdfdDWihoAL4b 2eTI6BvsTM79bfqjkrN8Xl/4PDSVXo7VjDk2vLBuyzPhfQQvGrpZf/bhlcv0WCTFLue+ Ksbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fZQXLkaL; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 22si1710953ejw.427.2021.09.09.05.11.35; Thu, 09 Sep 2021 05:12:03 -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=@kernel.org header.s=k20201202 header.b=fZQXLkaL; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346214AbhIIMLS (ORCPT + 99 others); Thu, 9 Sep 2021 08:11:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:42146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241531AbhIIMA1 (ORCPT ); Thu, 9 Sep 2021 08:00:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BC1FC61506; Thu, 9 Sep 2021 11:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187974; bh=KQitGf8LgkA60yKy0J2jv/cD9eB25l1vJw9SYw5CHR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fZQXLkaLhtOxGax+FxMHnIsDCN6gzeEksZ0BFJlgT6Vaz78gPHvtVsN1krW+4o0O8 3gXNNuDcPn71+s1Y3Z6Xj6Px9ETHmNwwJgUsS1kcukE+/SpYOpKyxRDyAJ4gd5Y5Ka ZoeFHNLtSRdV9Hlfp4gifaX+x5cPgg0XZdsrrmS59v+NyAAyl1JCShGysFnGGK0F0W jNn7cTEfz/qobBEBDEyXu7JYMICTJ0x1P0/PxfJ/pAT5rLRRNSlCh8CeDCrebfj0jh NNk/YLXhfK8kjgKq2LrD1TUB7xUtZDA/Ie/8wc4Znf4+4Jcy8Ss3nIM7Zka/kzNXnr QKDqKg+3PWh/w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wentao_Liang , Saeed Mahameed , Sasha Levin , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 237/252] net/mlx5: DR, fix a potential use-after-free bug Date: Thu, 9 Sep 2021 07:40:51 -0400 Message-Id: <20210909114106.141462-237-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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