kernel: increase reliability, add ksu_access_ok to simplify
Co-authored-by: backslashxx <118538522+backslashxx@users.noreply.github.com> Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
This commit is contained in:
@@ -79,15 +79,6 @@ void ksu_android_ns_fs_check()
|
||||
task_unlock(current);
|
||||
}
|
||||
|
||||
int ksu_access_ok(const void *addr, unsigned long size) {
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
|
||||
/* For kernels before 5.0.0, pass the type argument to access_ok. */
|
||||
return access_ok(VERIFY_READ, addr, size);
|
||||
#else
|
||||
/* For kernels 5.0.0 and later, ignore the type argument. */
|
||||
return access_ok(addr, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct file *ksu_filp_open_compat(const char *filename, int flags, umode_t mode)
|
||||
{
|
||||
@@ -188,3 +179,12 @@ 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user