Skip to content

Commit cdacde1

Browse files
committed
kernel: build: sucompat: hide / inline hook fns on syscall table hook
related: 7d33689 cant just flatten as some kernels already have heavy inlining by def. lets respect kernel kbuild instead Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
1 parent 8b086af commit cdacde1

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

kernel/feature/sucompat.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#ifdef CONFIG_KSU_TAMPER_SYSCALL_TABLE
2+
#define SUCOMPAT_HOOK_TYPE static __always_inline int
3+
#else
4+
#define SUCOMPAT_HOOK_TYPE int
5+
#endif
6+
17
#define SU_PATH "/system/bin/su"
28
#define SH_PATH "/system/bin/sh"
39

@@ -213,7 +219,7 @@ static __always_inline void ksu_sucompat_user_common(const char __user **filenam
213219
}
214220

215221
// sys_faccessat
216-
int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode, int *__unused_flags)
222+
SUCOMPAT_HOOK_TYPE ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode, int *__unused_flags)
217223
{
218224
if (!is_su_allowed((const void **)filename_user))
219225
return 0;
@@ -223,7 +229,7 @@ int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode,
223229
}
224230

225231
// sys_newfstatat, sys_fstat64
226-
int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags)
232+
SUCOMPAT_HOOK_TYPE ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags)
227233
{
228234
if (!is_su_allowed((const void **)filename_user))
229235
return 0;
@@ -233,7 +239,7 @@ int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags)
233239
}
234240

235241
// sys_execve, compat_sys_execve
236-
int ksu_handle_execve(const char __user **filename_user, void *argv, void *envp)
242+
SUCOMPAT_HOOK_TYPE ksu_handle_execve(const char __user **filename_user, void *argv, void *envp)
237243
{
238244

239245
#ifdef CONFIG_KSU_FEATURE_ADBROOT
@@ -247,7 +253,7 @@ int ksu_handle_execve(const char __user **filename_user, void *argv, void *envp)
247253
return 0;
248254
}
249255

250-
256+
#ifndef CONFIG_KSU_TAMPER_SYSCALL_TABLE
251257
static __always_inline void ksu_sucompat_kernel_common(void **restrict filename_ptr, void *restrict argv, void *restrict envp, const char *function_name)
252258
{
253259

@@ -326,6 +332,7 @@ int ksu_legacy_execve_sucompat(const char **filename_ptr, void *argv, void *envp
326332
return 0;
327333
}
328334
#endif
335+
#endif // CONFIG_KSU_TAMPER_SYSCALL_TABLE
329336

330337
#ifdef CONFIG_KSU_TAMPER_SYSCALL_TABLE
331338
static void syscall_table_sucompat_enable();

0 commit comments

Comments
 (0)