summarylogtreecommitdiffstats
path: root/access_ok_compat.patch
blob: 8c6caf3d234aaa3d60f498790ba317537ef78b65 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- a/eq3_char_loop.c	2020-03-27 23:57:42.975868561 +0100
+++ b/eq3_char_loop.c	2020-03-28 16:22:56.020584770 +0100
@@ -45,6 +45,12 @@
 #define EQ3LOOP_NUMBER_OF_CHANNELS 4
 #define EQ3LOOP_DRIVER_NAME "eq3loop"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))
+  #define _access_ok(__type, __addr, __size) access_ok(__addr, __size)
+#else
+  #define _access_ok(__type, __addr, __size) access_ok(__type, __addr, __size)
+#endif
+
 /* Use 'L' as magic number */
 #define EQ3LOOP_IOC_MAGIC  'L'
 
@@ -419,7 +425,7 @@
 	
 	/*
 	* extract the type and number bitfields, and don't decode
-	* wrong cmds: return ENOTTY (inappropriate ioctl) before access_ok()
+	* wrong cmds: return ENOTTY (inappropriate ioctl) before _access_ok()
 	*/
 	if (_IOC_TYPE(cmd) != EQ3LOOP_IOC_MAGIC) return -ENOTTY;
 
@@ -445,20 +451,20 @@
 	
 	/*
 	* extract the type and number bitfields, and don't decode
-	* wrong cmds: return ENOTTY (inappropriate ioctl) before access_ok()
+	* wrong cmds: return ENOTTY (inappropriate ioctl) before _access_ok()
 	*/
 	if (_IOC_TYPE(cmd) != EQ3LOOP_IOC_MAGIC) return -ENOTTY;
 
 	/*
 	* the direction is a bitmask, and VERIFY_WRITE catches R/W
 	* transfers. `Type' is user-oriented, while
-	* access_ok is kernel-oriented, so the concept of "read" and
+	* _access_ok is kernel-oriented, so the concept of "read" and
 	* "write" is reversed
 	*/
 	if (_IOC_DIR(cmd) & _IOC_READ)
-	ret = !access_ok(VERIFY_WRITE, (void *)arg, _IOC_SIZE(cmd));
+	ret = !_access_ok(VERIFY_WRITE, (void *)arg, _IOC_SIZE(cmd));
 	else if (_IOC_DIR(cmd) & _IOC_WRITE)
-	ret =  !access_ok(VERIFY_READ, (void *)arg, _IOC_SIZE(cmd));
+	ret =  !_access_ok(VERIFY_READ, (void *)arg, _IOC_SIZE(cmd));
 	if (ret) return -EFAULT;
 
 	switch(cmd) {
@@ -500,7 +506,7 @@
 	switch(cmd) {
 
 	case TCGETS:
-		if( access_ok(VERIFY_READ, (void *)arg, sizeof(struct termios) ) )
+		if( _access_ok(VERIFY_READ, (void *)arg, sizeof(struct termios) ) )
 		{
 			ret = copy_to_user( (void*)arg, &channel->termios, sizeof(struct termios) );
 		} else {
@@ -508,7 +514,7 @@
 		}
 		break;
 	case TCSETS:
-		if( access_ok(VERIFY_WRITE, (void *)arg, sizeof(struct termios) ) )
+		if( _access_ok(VERIFY_WRITE, (void *)arg, sizeof(struct termios) ) )
 		{
 			ret = copy_from_user( &channel->termios, (void*)arg, sizeof(struct termios) );
 		} else {