diff options
author | Tony Hutter <[email protected]> | 2019-01-10 11:03:40 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-01-28 10:11:10 -0800 |
commit | 77e50c3070a0009c4ed8b50dbb7cf0df48bdda90 (patch) | |
tree | 5dd8d9a703f9ae1392985eb9f363965d27e5c0af | |
parent | 5cb46f6a664db913f0ef2bf8e929c3f8d8cbfc5b (diff) |
Linux 5.0 compat: access_ok() drops 'type' parameter
access_ok no longer needs a 'type' parameter in the 5.0 kernel.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes #8261
-rw-r--r-- | config/kernel-access-ok-type.m4 | 21 | ||||
-rw-r--r-- | config/kernel.m4 | 1 | ||||
-rw-r--r-- | include/linux/kmap_compat.h | 8 | ||||
-rw-r--r-- | module/zcommon/zfs_uio.c | 3 |
4 files changed, 31 insertions, 2 deletions
diff --git a/config/kernel-access-ok-type.m4 b/config/kernel-access-ok-type.m4 new file mode 100644 index 000000000..3b2878a55 --- /dev/null +++ b/config/kernel-access-ok-type.m4 @@ -0,0 +1,21 @@ +dnl # +dnl # Linux 5.0: access_ok() drops 'type' parameter: +dnl # +dnl # - access_ok(type, addr, size) +dnl # + access_ok(addr, size) +dnl # +AC_DEFUN([ZFS_AC_KERNEL_ACCESS_OK_TYPE], [ + AC_MSG_CHECKING([whether access_ok() has 'type' parameter]) + ZFS_LINUX_TRY_COMPILE([ + #include <linux/uaccess.h> + ],[ + const void __user __attribute__((unused)) *addr = (void *) 0xdeadbeef; + unsigned long __attribute__((unused)) size = 1; + int error __attribute__((unused)) = access_ok(0, addr, size); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_ACCESS_OK_TYPE, 1, [kernel has access_ok with 'type' parameter]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 098c43700..ea04d85b6 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -4,6 +4,7 @@ dnl # AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL ZFS_AC_QAT + ZFS_AC_KERNEL_ACCESS_OK_TYPE ZFS_AC_TEST_MODULE ZFS_AC_KERNEL_MISC_MINOR ZFS_AC_KERNEL_OBJTOOL diff --git a/include/linux/kmap_compat.h b/include/linux/kmap_compat.h index 59ae566ce..b9c7f5bcc 100644 --- a/include/linux/kmap_compat.h +++ b/include/linux/kmap_compat.h @@ -27,6 +27,7 @@ #define _ZFS_KMAP_H #include <linux/highmem.h> +#include <linux/uaccess.h> #ifdef HAVE_1ARG_KMAP_ATOMIC /* 2.6.37 API change */ @@ -37,4 +38,11 @@ #define zfs_kunmap_atomic(addr, km_type) kunmap_atomic(addr, km_type) #endif +/* 5.0 API change - no more 'type' argument for access_ok() */ +#ifdef HAVE_ACCESS_OK_TYPE +#define zfs_access_ok(type, addr, size) access_ok(type, addr, size) +#else +#define zfs_access_ok(type, addr, size) access_ok(addr, size) +#endif + #endif /* _ZFS_KMAP_H */ diff --git a/module/zcommon/zfs_uio.c b/module/zcommon/zfs_uio.c index a2c1b5c3a..c1e31f51b 100644 --- a/module/zcommon/zfs_uio.c +++ b/module/zcommon/zfs_uio.c @@ -81,11 +81,10 @@ uiomove_iov(void *p, size_t n, enum uio_rw rw, struct uio *uio) return (EFAULT); } else { if (uio->uio_fault_disable) { - if (!access_ok(VERIFY_READ, + if (!zfs_access_ok(VERIFY_READ, (iov->iov_base + skip), cnt)) { return (EFAULT); } - pagefault_disable(); if (__copy_from_user_inatomic(p, (iov->iov_base + skip), cnt)) { |