]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Linux 5.0 compat: access_ok() drops 'type' parameter
authorTony Hutter <hutter2@llnl.gov>
Thu, 10 Jan 2019 19:03:40 +0000 (11:03 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 28 Jan 2019 18:11:10 +0000 (10:11 -0800)
access_ok no longer needs a 'type' parameter in the 5.0 kernel.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #8261

config/kernel-access-ok-type.m4 [new file with mode: 0644]
config/kernel.m4
include/linux/kmap_compat.h
module/zcommon/zfs_uio.c

diff --git a/config/kernel-access-ok-type.m4 b/config/kernel-access-ok-type.m4
new file mode 100644 (file)
index 0000000..3b2878a
--- /dev/null
@@ -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)
+       ])
+])
index 098c4370073a3b4309b4f5a92d37d626fd1db148..ea04d85b6cd75160cd9eccf28f282d6a73a9431d 100644 (file)
@@ -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
index 59ae566ce9d760a57d8f2681cdaf61441bc4064f..b9c7f5bcc9dcb6e7ef016a200e8a8106d9f33e97 100644 (file)
@@ -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 */
 #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 */
index a2c1b5c3aafe347bfedae18f3d2307da63cb7c73..c1e31f51be02ae9410dbd9792a76d9cb92699728 100644 (file)
@@ -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)) {