More check in rtdm mmap, also use kernel memory instead of virtual memory. stable-1.5
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Thu, 27 Sep 2018 17:56:16 +0200
branchstable-1.5
changeset 2713 2e2f57fd2131
parent 2712 5d21d80777a6
child 2714 ec417efca1fd
More check in rtdm mmap, also use kernel memory instead of virtual memory.
master/rtdm.c
--- a/master/rtdm.c	Thu Sep 27 00:21:27 2018 +0200
+++ b/master/rtdm.c	Thu Sep 27 17:56:16 2018 +0200
@@ -216,8 +216,12 @@
  */
 int ec_rtdm_mmap(struct rtdm_fd *fd, struct vm_area_struct *vma)
 {
-    ec_ioctl_context_t *ctx = (ec_ioctl_context_t *) rtdm_fd_to_private(fd);
-	return rtdm_mmap_vmem(vma, (void *)ctx->process_data);
-}
-
-/****************************************************************************/
+	size_t len;
+    ec_ioctl_context_t *ctx = (ec_ioctl_context_t *) rtdm_fd_to_private(fd);
+	len = vma->vm_end - vma->vm_start;
+	if (ctx->process_data_size != len)
+		return -EINVAL;
+	return rtdm_mmap_kmem(vma, (void *)ctx->process_data);
+}
+
+/****************************************************************************/