kernel: Replace ksu_access_ok with macro

Signed-off-by: rsuntk <rissu.ntk@gmail.com>
This commit is contained in:
rsuntk
2025-07-27 14:14:18 +07:00
committed by ShirkNeko
parent 0c87765958
commit 672041b4d6
3 changed files with 8 additions and 11 deletions

View File

@@ -178,12 +178,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
}

View File

@@ -45,5 +45,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

View File

@@ -155,7 +155,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