diff --git a/kernel/kernel_compat.c b/kernel/kernel_compat.c index 50d0feb1..8de66319 100644 --- a/kernel/kernel_compat.c +++ b/kernel/kernel_compat.c @@ -179,12 +179,3 @@ long ksu_strncpy_from_user_nofault(char *dst, const void __user *unsafe_addr, return ret; } #endif - -int ksu_access_ok(const void *addr, unsigned long size) -{ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) - return access_ok(addr, size); -#else - return access_ok(VERIFY_READ, addr, size); -#endif -} diff --git a/kernel/kernel_compat.h b/kernel/kernel_compat.h index 1a80a3ea..9152e961 100644 --- a/kernel/kernel_compat.h +++ b/kernel/kernel_compat.h @@ -64,5 +64,11 @@ extern ssize_t ksu_kernel_read_compat(struct file *p, void *buf, size_t count, loff_t *pos); extern ssize_t ksu_kernel_write_compat(struct file *p, const void *buf, size_t count, loff_t *pos); -extern int ksu_access_ok(const void *addr, unsigned long size); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#define ksu_access_ok(addr, size) (access_ok(addr, size)) +#else +#define ksu_access_ok(addr, size) (access_ok(VERIFY_READ, addr, size)) +#endif + #endif diff --git a/kernel/sucompat.c b/kernel/sucompat.c index 28a73b52..83ba6f52 100644 --- a/kernel/sucompat.c +++ b/kernel/sucompat.c @@ -218,7 +218,7 @@ int ksu_handle_execve_sucompat(int *fd, const char __user **filename_user, * some cpus dont really have that good speculative execution * access_ok to substitute set_fs, we check if pointer is accessible */ - if (!ksu_access_ok((const void *)filename_user, sizeof(path))) + if (!ksu_access_ok(*filename_user, sizeof(path))) return 0; // success = returns number of bytes and should be less than path