From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AFF149659; Mon, 14 Oct 2024 15:00:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918056; cv=none; b=Q+8bly6/2JbU+82MA86mT+74QY0gIvmGp5OcGXEmQ3GaQtqfAm8G4ZJgz1Bf5zkgz9Dhxxswkm+zUDmlZGYssOCMGEuY9Ul3YHxF+zjfahOKJsbV3v5RWhx4JDdxQJatgwHxA8pA7xPrS4iyjn6WmxHxq08ynMDUZYp2hxTuKsM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918056; c=relaxed/simple; bh=ZaY2dcJPcOeZcRM4okw6cybXImLiGehrM7WTV9a/z24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IyhM2Bcnc+tfv2GBDRXlUs5mvIfbmkMkCc1Zxqad46FFLHKaPWgyJ49Bh/ry1D4K/jpjjW82hye6AHJ4pROUoVthdYWstLib3ILyr3oJLsl6p31lchHER7/dYG2VDgJrMOckeYFdVUMBeE394MAOjNMQoM3F7pr6kGotbgXa9f8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DcPgLCol; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DcPgLCol" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B36CC4CEC3; Mon, 14 Oct 2024 15:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728918056; bh=ZaY2dcJPcOeZcRM4okw6cybXImLiGehrM7WTV9a/z24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DcPgLColydPxfakzghSUTk0kph8gZlmmv3HbF+yEbo8M8RO8wFhvrh5ea9011bILr RK3JCkG+7D5ZuG00SjLZWO7e5DqlawrrGU0ilptZImiR7OEbMSGOtduaU3zSSd1nYO MQVF4R5kMRB4gu+28Q/BmgPWHWWHRjY4umDwC1EE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Md Haris Iqbal , Jack Wang , Grzegorz Prajsner , Leon Romanovsky , Sasha Levin Subject: [PATCH 6.1 209/798] RDMA/rtrs-clt: Reset cid to con_num - 1 to stay in bounds Date: Mon, 14 Oct 2024 16:12:43 +0200 Message-ID: <20241014141226.142710554@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141217.941104064@linuxfoundation.org> References: <20241014141217.941104064@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Md Haris Iqbal [ Upstream commit 3e4289b29e216a55d08a89e126bc0b37cbad9f38 ] In the function init_conns(), after the create_con() and create_cm() for loop if something fails. In the cleanup for loop after the destroy tag, we access out of bound memory because cid is set to clt_path->s.con_num. This commits resets the cid to clt_path->s.con_num - 1, to stay in bounds in the cleanup loop later. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang Signed-off-by: Grzegorz Prajsner Link: https://patch.msgid.link/20240821112217.41827-7-haris.iqbal@ionos.com Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 9beae1e50d115..dac8ddfc89e7d 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2343,6 +2343,12 @@ static int init_conns(struct rtrs_clt_path *clt_path) if (err) goto destroy; } + + /* + * Set the cid to con_num - 1, since if we fail later, we want to stay in bounds. + */ + cid = clt_path->s.con_num - 1; + err = alloc_path_reqs(clt_path); if (err) goto destroy; -- 2.43.0