Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
bmax committed Apr 3, 2024
1 parent c750b10 commit ae0b52b
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions kernel/patch/android/sucompat.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,22 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen

// argv
int argv_cplen = 0;
if (strcmp(legacy_su_path, filename)) {
#ifdef TRY_DIRECT_MODIFY_USER
const char __user *p1 = get_user_arg_ptr(0, *uargv, 0);
argv_cplen = compat_copy_to_user((void *__user)p1, legacy_su_path, sizeof(legacy_su_path));
const char __user *p1 = get_user_arg_ptr(0, *uargv, 0);
argv_cplen = compat_copy_to_user((void *__user)p1, legacy_su_path, sizeof(legacy_su_path));
#endif
if (argv_cplen <= 0) {
sp = sp ?: current_user_stack_pointer();
sp -= sizeof(legacy_su_path);
sp &= 0xFFFFFFFFFFFFFFF8;
argv_cplen = compat_copy_to_user((void *)sp, legacy_su_path, sizeof(legacy_su_path));
if (argv_cplen > 0) {
int rc = set_user_arg_ptr(0, *uargv, 0, sp);
if (rc < 0) { // todo: modify entire argv
logkfi("call apd argv error, uid: %d, to_uid: %d, sctx: %s, rc: %d\n", uid, to_uid, sctx, rc);
if (argv_cplen <= 0) {
sp = sp ?: current_user_stack_pointer();
sp -= sizeof(legacy_su_path);
sp &= 0xFFFFFFFFFFFFFFF8;
argv_cplen = compat_copy_to_user((void *)sp, legacy_su_path, sizeof(legacy_su_path));
if (argv_cplen > 0) {
int rc = set_user_arg_ptr(0, *uargv, 0, sp);
if (rc < 0) { // todo: modify entire argv
logkfi("call apd argv error, uid: %d, to_uid: %d, sctx: %s, rc: %d\n", uid, to_uid, sctx,
rc);
}
}
}
}
Expand Down

0 comments on commit ae0b52b

Please sign in to comment.