From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5089A418A58; Tue, 21 Jul 2026 22:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671738; cv=none; b=pV5h0FcAQqAJLAHtHaMDq6Twi7jBzkyOZWacRdUMRlW3hWl0I9GOG5buT9tT1LE8nQwWsVbM8DcPBV41RQl/RkAqowjxQv7fIBL3jl+qVBbv2HK+roYAfJ8OeGt/RWmq+8/DqTuEqa0GLJkDmZDx42SOtgE36/h9/DjvscH/Dhg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671738; c=relaxed/simple; bh=yKbU20COce5BxqIDHrWzAAimnbLA+fFLWyTAd+ijTR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WTa+MBGEXHv/rbR72fneucRxSi0z09RcPQhBShsFSZWIR51j/XKbrQ850kLWR3jv+FQlT9dZOUdyVMeqTUl3HxvQ5k4i9dls9gqcDvrb5B8CQnS74n1C64Y0WqKhxYs+/XG3uWW7Q6GhYaZlAqZve1YjwmGG/XXLzLkLRcuzsSE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dkmxe5Rr; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dkmxe5Rr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE44D1F000E9; Tue, 21 Jul 2026 22:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784671733; bh=Fge1C3wi/Y+dR6N+wAf/KtKGDzEdnhuQqpV2Zf6EScc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dkmxe5RrmUgdG5y7JPZJWt3cFDofTUxAaNx4XrBvBd6/KR2U77PRTYLegGPAv3LyC 7RPEECKuEyTBSWc6mAxCVDjCSksWdsSv/zutDzaNZdnN+nF65IVmglcWwNYRODF6xS 5vdWzSP2pAUhUlsNHH8dV+6vUzX/SSPTAKrPf8tI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.15 315/843] IB/mlx5: Properly support implicit ODP rereg_mr Date: Tue, 21 Jul 2026 17:19:10 +0200 Message-ID: <20260721152413.107419786@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Gunthorpe [ Upstream commit ee7a8335069150c3f1893a697ab30bbeca00d796 ] Due to all the child mkeys in the implicit ODP configuration we cannot change anything in place for the parent mkey. Instead the whole thing needs to be rebuilt if any change is requested. If the user does not specify a translation then force the implicit values which will then fall through the logic into mlx5_ib_reg_user_mr() to allocate a completely new MR. Since implicit children were also touching the mr->pd, this removes another case where the access was racy. Fixes: ef3642c4f54d ("RDMA/mlx5: Fix error unwinds for rereg_mr") Link: https://sashiko.dev/#/patchset/20260427-security-bug-fixes-v3-0-4621fa52de0e%40nvidia.com?part=4 Link: https://patch.msgid.link/r/3-v1-29ebd2c229b5+fd5-ib_mr_pd_jgg@nvidia.com Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx5/mr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index fca92b5128c660..fad5cfd1756e09 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1815,6 +1815,21 @@ struct ib_mr *mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, if (!(flags & IB_MR_REREG_PD)) new_pd = ib_mr->pd; + if (mr->is_odp_implicit && !(flags & IB_MR_REREG_TRANS)) { + if (!(new_access_flags & IB_ACCESS_ON_DEMAND)) + return ERR_PTR(-EOPNOTSUPP); + + /* + * Due to all the child mkeys we cannot actually change an + * implicit MR in place. If the user did not specify a new + * translation then force the fixed implicit MR values. + */ + start = 0; + iova = 0; + length = U64_MAX; + flags |= IB_MR_REREG_TRANS; + } + if (!(flags & IB_MR_REREG_TRANS)) { struct ib_umem *umem; -- 2.53.0