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 <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #8261
This commit is contained in:
Tony Hutter 2019-01-10 11:03:40 -08:00
parent 98bb45e27a
commit edc2675aed
4 changed files with 31 additions and 2 deletions

View File

@ -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)
])
])

View File

@ -5,6 +5,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL ZFS_AC_KERNEL
ZFS_AC_SPL ZFS_AC_SPL
ZFS_AC_QAT ZFS_AC_QAT
ZFS_AC_KERNEL_ACCESS_OK_TYPE
ZFS_AC_TEST_MODULE ZFS_AC_TEST_MODULE
ZFS_AC_KERNEL_MISC_MINOR ZFS_AC_KERNEL_MISC_MINOR
ZFS_AC_KERNEL_OBJTOOL ZFS_AC_KERNEL_OBJTOOL

View File

@ -27,6 +27,7 @@
#define _ZFS_KMAP_H #define _ZFS_KMAP_H
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/uaccess.h>
#ifdef HAVE_1ARG_KMAP_ATOMIC #ifdef HAVE_1ARG_KMAP_ATOMIC
/* 2.6.37 API change */ /* 2.6.37 API change */
@ -37,4 +38,11 @@
#define zfs_kunmap_atomic(addr, km_type) kunmap_atomic(addr, km_type) #define zfs_kunmap_atomic(addr, km_type) kunmap_atomic(addr, km_type)
#endif #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 */ #endif /* _ZFS_KMAP_H */

View File

@ -79,11 +79,10 @@ uiomove_iov(void *p, size_t n, enum uio_rw rw, struct uio *uio)
return (EFAULT); return (EFAULT);
} else { } else {
if (uio->uio_fault_disable) { if (uio->uio_fault_disable) {
if (!access_ok(VERIFY_READ, if (!zfs_access_ok(VERIFY_READ,
(iov->iov_base + skip), cnt)) { (iov->iov_base + skip), cnt)) {
return (EFAULT); return (EFAULT);
} }
pagefault_disable(); pagefault_disable();
if (__copy_from_user_inatomic(p, if (__copy_from_user_inatomic(p,
(iov->iov_base + skip), cnt)) { (iov->iov_base + skip), cnt)) {