Skip to content

Commit 95695e3

Browse files
author
bmax
committed
opt
1 parent 6fe3bcb commit 95695e3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

kernel/patch/android/sucompat.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen
376376
}
377377
}
378378

379+
#ifdef TRY_DIRECT_MODIFY_USER
379380
static void handle_after_execve(hook_local_t *hook_local)
380381
{
381382
int cplen = hook_local->data0;
@@ -384,6 +385,7 @@ static void handle_after_execve(hook_local_t *hook_local)
384385
compat_copy_to_user((void *)*u_filename_p, current_su_path, cplen);
385386
}
386387
}
388+
#endif
387389

388390
// https://elixir.bootlin.com/linux/v6.1/source/fs/exec.c#L2087
389391
// SYSCALL_DEFINE3(execve, const char __user *, filename, const char __user *const __user *, argv,
@@ -395,10 +397,14 @@ static void before_execve(hook_fargs3_t *args, void *udata)
395397
handle_before_execve(&args->local, (char **)arg0p, (char **)arg1p, udata);
396398
}
397399

400+
#ifdef TRY_DIRECT_MODIFY_USER
398401
static void after_execve(hook_fargs3_t *args, void *udata)
399402
{
400403
handle_after_execve(&args->local);
401404
}
405+
#else
406+
#define after_execve 0
407+
#endif
402408

403409
// https://elixir.bootlin.com/linux/v6.1/source/fs/exec.c#L2095
404410
// SYSCALL_DEFINE5(execveat, int, fd, const char __user *, filename, const char __user *const __user *, argv,
@@ -410,10 +416,14 @@ static void before_execveat(hook_fargs5_t *args, void *udata)
410416
handle_before_execve(&args->local, (char **)arg1p, (char **)arg2p, udata);
411417
}
412418

419+
#ifdef TRY_DIRECT_MODIFY_USER
413420
static void after_execveat(hook_fargs5_t *args, void *udata)
414421
{
415422
handle_after_execve(&args->local);
416423
}
424+
#else
425+
#define after_execveat 0
426+
#endif
417427

418428
// https://elixir.bootlin.com/linux/v6.1/source/fs/stat.c#L431
419429
// SYSCALL_DEFINE4(newfstatat, int, dfd, const char __user *, filename,
@@ -462,13 +472,17 @@ static void su_handler_arg1_ufilename_before(hook_fargs6_t *args, void *udata)
462472
}
463473
}
464474

475+
#ifdef TRY_DIRECT_MODIFY_USER
465476
static void su_handler_arg1_ufilename_after(hook_fargs6_t *args, void *udata)
466477
{
467478
int cplen = args->local.data0;
468479
if (cplen > 0) {
469480
compat_copy_to_user((void *)args->local.data1, current_su_path, cplen);
470481
}
471482
}
483+
#else
484+
#define su_handler_arg1_ufilename_after 0
485+
#endif
472486

473487
int su_compat_init()
474488
{

0 commit comments

Comments
 (0)