Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supercall: Add SUPERCALL_SU_GET_SAFEMODE #101

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions kernel/patch/android/userd.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,6 @@ static void before_input_handle_event(hook_fargs4_t *args, void *udata)
if (volumedown_pressed_count == 3) {
log_boot("entering safemode ...");
android_is_safe_mode = 1;
struct file *filp = filp_open(SAFE_MODE_FLAG_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (filp && !IS_ERR(filp)) filp_close(filp, 0);
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions kernel/patch/common/supercall.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ static long call_su_allow_uid_nums()
return su_allow_uid_nums();
}

#ifdef ANDROID
extern int android_is_safe_mode;
static long call_su_get_safemode()
{
int result = android_is_safe_mode;
logkfd("[call_su_get_safemode] %d\n", result);
return result;
}
#endif

static long call_su_list_allow_uid(uid_t *__user uids, int num)
{
return su_allow_uids(1, uids, num);
Expand Down Expand Up @@ -276,6 +286,10 @@ static long supercall(int is_key_auth, long cmd, long arg1, long arg2, long arg3
return call_su_get_allow_sctx((char *__user)arg1, (int)arg2);
case SUPERCALL_SU_SET_ALLOW_SCTX:
return call_su_set_allow_sctx((char *__user)arg1);
#ifdef ANDROID
case SUPERCALL_SU_GET_SAFEMODE:
return call_su_get_safemode();
#endif
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions kernel/patch/include/uapi/scdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct su_profile
#define SUPERCALL_SU_SET_ALLOW_SCTX 0x1106
#define SUPERCALL_SU_GET_PATH 0x1110
#define SUPERCALL_SU_RESET_PATH 0x1111
#define SUPERCALL_SU_GET_SAFEMODE 0x1112

#define SUPERCALL_MAX 0x1200

Expand Down
12 changes: 12 additions & 0 deletions user/supercall.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,18 @@ static inline long sc_skey_root_enable(const char *key, bool enable)
return ret;
}

/**
* @brief Get whether in safe mode
*
* @param key
* @return long
*/
static inline long sc_su_get_safemode(const char *key)
{
if (!key || !key[0]) return -EINVAL;
return syscall(__NR_supercall, key, compact_cmd(key, SUPERCALL_SU_GET_SAFEMODE));
}

// todo
static inline long sc_pid_virt_to_phys(const char *key, pid_t pid, unsigned long vaddr)
{
Expand Down
Loading