summarylogtreecommitdiffstats
path: root/0002-kernel-5.0.0-access_ok.patch
blob: c65bdc457d2e2f7798858fb3ef8ecba214098222 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
--- npreal2.c.orig	2017-11-10 02:25:03.000000000 -0500
+++ npreal2.c	2019-03-10 21:28:04.465949059 -0400
@@ -1317,19 +1317,25 @@ static int npreal_ioctl(struct tty_struc
 			return(retval);
 		tty_wait_until_sent(tty, 0);
 		npreal_send_break(info, arg ? arg*(HZ/10) : HZ/4);
 		return(0);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
+#define compat_access_ok(u,v,w) access_ok(v,w)
+#else
+#define compat_access_ok(u,v,w) access_ok(u,v,w)
+#endif
+
 	case TIOCGSOFTCAR:
-		error = access_ok(VERIFY_WRITE, (void *)arg, sizeof(long))?0:-EFAULT;
+		error = compat_access_ok(VERIFY_WRITE, (void *)arg, sizeof(long))?0:-EFAULT;
 		if ( error )
 			return(error);
 		put_to_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *)arg);
 		return 0;
 
 	case TIOCSSOFTCAR:
-		error = access_ok(VERIFY_READ, (void *)arg, sizeof(long))?0:-EFAULT;
+		error = compat_access_ok(VERIFY_READ, (void *)arg, sizeof(long))?0:-EFAULT;
 		if ( error )
 			return(error);
 		get_from_user(templ,(unsigned long *)arg);
 		arg = templ;
 #if (LINUX_VERSION_CODE < VERSION_CODE(3,7,0))		
@@ -1340,25 +1346,25 @@ static int npreal_ioctl(struct tty_struc
 				(arg ? CLOCAL : 0));
 #endif
 		return(0);
 
 	case TIOCGSERIAL:
-		error = access_ok(VERIFY_WRITE, (void *)arg,
+		error = compat_access_ok(VERIFY_WRITE, (void *)arg,
 				sizeof(struct serial_struct))?0:-EFAULT;
 		if ( error )
 			return(error);
 		return(npreal_get_serial_info(info, (struct serial_struct *)arg));
 
 	case TIOCSSERIAL:
-		error = access_ok(VERIFY_READ, (void *)arg,
+		error = compat_access_ok(VERIFY_READ, (void *)arg,
 				sizeof(struct serial_struct))?0:-EFAULT;
 		if ( error )
 			return(error);
 		return(npreal_set_serial_info(info, (struct serial_struct *)arg));
 
 	case TIOCSERGETLSR: /* Get line status register */
-		error = access_ok(VERIFY_WRITE, (void *)arg,
+		error = compat_access_ok(VERIFY_WRITE, (void *)arg,
 				sizeof(unsigned int))?0:-EFAULT;
 		if ( error )
 			return(error);
 		else
 			return(npreal_get_lsr_info(info, (unsigned int *)arg));
@@ -1411,11 +1417,11 @@ static int npreal_ioctl(struct tty_struc
 	 * Return: write counters to the user passed counter struct
 	 * NB: both 1->0 and 0->1 transitions are counted except for
 	 *     RI where only 0->1 is counted.
 	 */
 	case TIOCGICOUNT:
-		error = access_ok(VERIFY_WRITE, (void *)arg,
+		error = compat_access_ok(VERIFY_WRITE, (void *)arg,
 				sizeof(struct serial_icounter_struct))?0:-EFAULT;
 		if ( error )
 			return(error);
 		cnow = info->icount;
 		p_cuser = (struct serial_icounter_struct *)arg;
@@ -3369,11 +3375,11 @@ npreal_net_ioctl (
 		}
 		if (nd->flag & NPREAL_NET_DO_SESSION_RECOVERY)
 			len = nd->do_session_recovery_len;
 		else
 			len = (int)nd->cmd_buffer[2] + 3;
-		rtn = access_ok( VERIFY_WRITE, (void *)arg, len)?0:-EFAULT;
+		rtn = compat_access_ok( VERIFY_WRITE, (void *)arg, len)?0:-EFAULT;
 		if ( rtn )
 		{
 			goto done;
 		}
 		if (copy_to_user( (void *)arg, (void *)nd->cmd_buffer,len ))
@@ -3393,11 +3399,11 @@ npreal_net_ioctl (
 		if (size < 2)
 			goto done;
 		if (size > 84)
 			size = 84;
 
-		rtn = access_ok( VERIFY_READ,  (void *)arg, size )?0:-EFAULT;
+		rtn = compat_access_ok( VERIFY_READ,  (void *)arg, size )?0:-EFAULT;
 		if ( rtn )
 		{
 			goto done;
 		}
 		if (copy_from_user( (void *)rsp_buffer, (void *)arg,size))
@@ -3518,11 +3524,11 @@ npreal_net_ioctl (
 		int	status;
 
 		if (size != sizeof (status))
 			goto done;
 
-		rtn = access_ok( VERIFY_READ,  (void *)arg, size )?0:-EFAULT;
+		rtn = compat_access_ok( VERIFY_READ,  (void *)arg, size )?0:-EFAULT;
 		if ( rtn )
 		{
 			goto done;
 		}
 		status = (nd->flag & NPREAL_NET_TTY_INUSED) ? 1 : 0;
@@ -3543,11 +3549,11 @@ npreal_net_ioctl (
 			break;
 
 		if (size != sizeof (struct server_setting_struct))
 			goto done;
 
-		rtn = access_ok( VERIFY_READ,  (void *)arg, size )?0:-EFAULT;
+		rtn = compat_access_ok( VERIFY_READ,  (void *)arg, size )?0:-EFAULT;
 		if ( rtn )
 		{
 			goto done;
 		}
 		if (copy_from_user( (void *)&settings, (void *)arg,size))