From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387735; b=WtPNO0ylwWE1/A2Q+gVTARC4Jusj1XJKnId2G63TtIc2NNHbuiLXzqtM+KeQH5JL08Rd nn2Ycdeqigke+pOfWC9X0CDYpqcwkgVdepdyDVOgLomjETAYqc6o/gBqrz/mgUyw5ij7N 9L4rlgzwHnBfUcQ6bM0zhvlGxCmAZDAy+xIIbalIWyhj0RbCc2ogcNCq3OrmrEQsncm7o rbdcCGyDic4ATVfyqzuMUo4l+azvtZiUdJY3KaAr7PPaFhR6N1LTlTtgFFiYvwe9jPMKj reHfwjIyPhLGgSGugeRgeGpQU5SN7K97VTAETKJh/Rkkk/TswVyQHzmM33qnQLfOcdA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387735; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=47dwCFkg8q1iMB4q2Y5wZAkzSFfnkUw1hCO/4L+786M=; b=ggvAzfxAu2E8EEJ19kEXaYwd9c8QP8XY1QlSuL9V5ylq1SCRJZozEVNbPkVn4CI6ehyE pCPJx1B3uSFoBMNl9/3mhGFzUSkWPdz5/dNS6gFJbJOLR10Izax4yEz7G4BvIHK2rYPEx xeRL2LtPXkQzK+lIX7i26YSN5Oko4M1kyKJY2a0Hh5En+4V6N7/aaROFF0jn7vpGOISfS RS82jO6JfUSrfa+9CzagklS98FGGxEBvsXS/EqX60Jif3zfNBJ9xhMaihprEie7vHHYtx EC+Z9J0uAPxj4gwCPYulWWzB8iAeEdPOa2HToiKEUd7PjOv8+dL88QzsIvb3l7iUjkA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LT4DwMy2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82E7E606A322; Fri, 4 Dec 2026 12:35:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LT4DwMy2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDB8D1F000CE; Fri, 4 Dec 2026 12:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387735; bh=47dwCFkg8q1iMB4q2Y5wZAkzSFfnkUw1hCO/4L+786M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LT4DwMy2prIp+bk1plRz/43WCRl0CzMzB3PUP4qRjU9++wgDxw9Kyf2gWJu1mo2PH CX9XDAHmjqo2itcdRlfk0En6J3cfKTgWZiZmPQBAnyY2kre7bnq8G4n/t+ML+UW3jj rq8da+8otZrA3ayu24ZqpVq06Yan4gSTeR6woT7c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiale Yao , Leon Romanovsky , Sasha Levin Subject: [PATCH 6.1 0317/1059] RDMA/mlx4: Do not allow the user to write to the clock page Date: Fri, 4 Dec 2026 18:57:28 +0900 Message-ID: <20261204100652.480726161@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiale Yao [ Upstream commit 33db1d9683b8fb00bc233d0bea093e694ed9afc5 ] mlx4_ib_mmap() maps the internal clock page to userspace through rdma_user_mmap_io(), which does not restrict write access. Userspace can request PROT_WRITE directly, or upgrade a read-only mapping later with mprotect() because VM_MAYWRITE remains set. Reject VM_WRITE, VM_EXEC and clear VM_MAYWRITE, applying the same read-only policy as commit c660133c339f ("RDMA/mlx5: Do not allow the user to write to the clock page"). The rdma-core mlx4 provider requests this mapping with PROT_READ, so its existing behavior is unchanged. Fixes: 52033cfb5aab ("IB/mlx4: Add mmap call to map the hardware clock") Signed-off-by: Jiale Yao Link: https://patch.msgid.link/20260926111150.3197004-1-yaojiale02@163.com Signed-off-by: Leon Romanovsky [ sashal: Replaced the missing vm_flags_clear(vma, VM_MAYWRITE) helper with the open-coded vma->vm_flags &= ~VM_MAYWRITE. ] Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx4/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 0f0b130cc8aac..cc0a8b71add4a 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -1171,6 +1171,10 @@ static int mlx4_ib_mmap(struct ib_ucontext *context, struct vm_area_struct *vma) struct mlx4_clock_params params; int ret; + if (vma->vm_flags & (VM_WRITE | VM_EXEC)) + return -EPERM; + vma->vm_flags &= ~VM_MAYWRITE; + ret = mlx4_get_internal_clock_params(dev->dev, ¶ms); if (ret) return ret; -- 2.53.0