summarylogtreecommitdiffstats
path: root/02-fix-get_user_pages-and-mmap_lock.patch
blob: 68b378bef3d2387f5d2815296ddc36cb5a7e3a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
diff --git a/blackmagic-11.6a26/blackmagic_lib.c.orig b/blackmagic-11.6a26/blackmagic_lib.c
index 83fab89..35b54b5 100644
--- a/blackmagic-11.6a26/blackmagic_lib.c.orig
+++ b/blackmagic-11.6a26/blackmagic_lib.c
@@ -670,9 +670,17 @@ dl_get_user_pages(void *task_ptr, void *ptr, unsigned long size, unsigned long *
 		write = 1;
 	else
 		write = 0;
-	
+#if KERNEL_VERSION_OR_LATER(5, 8, 0)
+	down_read(&current_task->mm->mmap_lock);
+#else
 	down_read(&current_task->mm->mmap_sem);
-#if KERNEL_VERSION_OR_LATER(4, 10, 0)
+#endif
+#if KERNEL_VERSION_OR_LATER(5, 9, 0)
+		if (current_task == current)
+			ret = get_user_pages((unsigned long)ptr & PAGE_MASK, *nr_pages, write ? FOLL_WRITE : 0, pages, NULL);
+		else
+			ret = get_user_pages_remote(current_task->mm, (unsigned long)ptr & PAGE_MASK, *nr_pages, write ? FOLL_WRITE : 0, pages, NULL, NULL);
+#elif KERNEL_VERSION_OR_LATER(4, 10, 0)
 		if (current_task == current)
 			ret = get_user_pages((unsigned long)ptr & PAGE_MASK, *nr_pages, write ? FOLL_WRITE : 0, pages, NULL);
 		else
@@ -692,7 +700,12 @@ dl_get_user_pages(void *task_ptr, void *ptr, unsigned long size, unsigned long *
 #else
 		ret = get_user_pages(current_task, current_task->mm, (unsigned long)ptr & PAGE_MASK, *nr_pages, write, 0, pages, NULL);
 #endif
+
+#if KERNEL_VERSION_OR_LATER(5, 8, 0)
+	up_read(&current_task->mm->mmap_lock);
+#else
 	up_read(&current_task->mm->mmap_sem);
+#endif
 	
 	if (ret < (long)*nr_pages)
 	{