summarylogtreecommitdiffstats
path: root/access_ok_compat.patch
diff options
context:
space:
mode:
Diffstat (limited to 'access_ok_compat.patch')
-rw-r--r--access_ok_compat.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/access_ok_compat.patch b/access_ok_compat.patch
new file mode 100644
index 000000000000..8c6caf3d234a
--- /dev/null
+++ b/access_ok_compat.patch
@@ -0,0 +1,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 {