summarylogtreecommitdiffstats
path: root/linux-4.8-usercopy.patch
diff options
context:
space:
mode:
authorAlex Wiggins2016-12-21 22:57:35 +0000
committerAlex Wiggins2016-12-21 22:57:35 +0000
commit40d91e89d4bffc0e4f41a6051d041f2eb9456a0a (patch)
tree8f6b2d208faa45601f089956bd56ab1eaf1950be /linux-4.8-usercopy.patch
parent7ba3b086987376a0689b36a120436cbc3dfa840b (diff)
downloadaur-40d91e89d4bffc0e4f41a6051d041f2eb9456a0a.tar.gz
Add patch for kernel 4.8 CONFIG_HARDENED_USERCOPY
Diffstat (limited to 'linux-4.8-usercopy.patch')
-rw-r--r--linux-4.8-usercopy.patch44
1 files changed, 44 insertions, 0 deletions
diff --git a/linux-4.8-usercopy.patch b/linux-4.8-usercopy.patch
new file mode 100644
index 000000000000..7ff26c08914a
--- /dev/null
+++ b/linux-4.8-usercopy.patch
@@ -0,0 +1,44 @@
+--- kernel/OS/Linux/os_linux.c 2015-01-28 08:07:23.000000000 +0000
++++ kernel/OS/Linux/os_linux.c 2016-12-21 22:38:46.369612126 +0000
+@@ -640,7 +640,8 @@
+ int dev = d;
+ oss_cdev_t *cdev;
+ int err;
+- int localbuf[64]; /* 256 bytes is the largest frequently used ioctl size */
++ /* Remove localbuf (workaround for CONFIG_HARDENED_USERCOPY from kernel 4.8) */
++ /* int localbuf[64]; */ /* 256 bytes is the largest frequently used ioctl size */
+
+ int len = 0;
+ int alloced = 0;
+@@ -666,14 +667,18 @@
+ return OSS_EFAULT;
+ }
+
++ /* Always use dynamic kernel memory allocation (instead of static localbuf)
++ (workaround for CONFIG_HARDENED_USERCOPY from kernel 4.8) */
++ ptr = KERNEL_MALLOC (len);
++ alloced = 1;
+ /* Use statically allocated buffer for short arguments */
+- if (len > sizeof (localbuf))
++ /*if (len > sizeof (localbuf))
+ {
+ ptr = KERNEL_MALLOC (len);
+ alloced = 1;
+ }
+ else
+- ptr = localbuf;
++ ptr = localbuf;*/
+
+ if (ptr == NULL || arg == 0)
+ {
+@@ -710,8 +715,8 @@
+
+ /* Free the local buffer unless it was statically allocated */
+ if (ptr != NULL && alloced)
+- if (len > sizeof (localbuf))
+- KERNEL_FREE (ptr);
++// if (len > sizeof (localbuf))
++ KERNEL_FREE (ptr);
+
+ return ((err < 0) ? err : 0);
+