sukisu/kernel/kernel_compat.h

25 lines
558 B
C
Raw Normal View History

2025-11-20 21:18:19 +01:00
#ifndef __KSU_H_KERNEL_COMPAT
#define __KSU_H_KERNEL_COMPAT
#include <linux/fs.h>
#include <linux/version.h>
/*
* ksu_copy_from_user_retry
* try nofault copy first, if it fails, try with plain
* paramters are the same as copy_from_user
* 0 = success
*/
static long ksu_copy_from_user_retry(void *to,
2025-11-20 21:24:53 +01:00
const void __user *from, unsigned long count)
2025-11-20 21:18:19 +01:00
{
2025-11-20 21:24:53 +01:00
long ret = copy_from_user_nofault(to, from, count);
if (likely(!ret))
return ret;
2025-11-20 21:18:19 +01:00
2025-11-20 21:24:53 +01:00
// we faulted! fallback to slow path
return copy_from_user(to, from, count);
2025-11-20 21:18:19 +01:00
}
#endif