Skip to content

Commit

Permalink
properly handle is_ksu_domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylarod committed Jan 4, 2024
1 parent 670d094 commit ba741b2
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions kernel/selinux/selinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,15 @@ static inline u32 current_sid(void)
}
#endif

static u32 ksu_sid = 0;

bool is_ksu_domain()
{
int error;
u32 sid;
if (!ksu_sid) {
error = security_secctx_to_secid(KERNEL_SU_DOMAIN, strlen(KERNEL_SU_DOMAIN), &sid);
if (error) {
pr_info("security_secctx_to_secid %s -> sid: %d, error: %d\n",
KERNEL_SU_DOMAIN, sid, error);
}
if (!error) {
if (!ksu_sid)
ksu_sid = sid;
}
char *domain;
u32 seclen;
int err = security_secid_to_secctx(current_sid(), &domain, &seclen);
if (err) {
return false;
}
return ksu_sid && current_sid() == ksu_sid;
return strncmp(KERNEL_SU_DOMAIN, domain, seclen) == 0;
}

bool is_zygote(void *sec)
Expand Down

0 comments on commit ba741b2

Please sign in to comment.