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

Correctly handle is_ksu_domain, close #972 #1246

Merged
merged 3 commits into from
Jan 4, 2024
Merged
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
13 changes: 7 additions & 6 deletions kernel/selinux/selinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#define KERNEL_SU_DOMAIN "u:r:su:s0"

static u32 ksu_sid;

static int transive_to_domain(const char *domain)
{
struct cred *cred;
Expand All @@ -31,9 +29,6 @@ static int transive_to_domain(const char *domain)
domain, sid, error);
}
if (!error) {
if (!ksu_sid)
ksu_sid = sid;

tsec->sid = sid;
tsec->create_sid = 0;
tsec->keycreate_sid = 0;
Expand Down Expand Up @@ -106,7 +101,13 @@ static inline u32 current_sid(void)

bool is_ksu_domain()
{
return ksu_sid && current_sid() == ksu_sid;
char *domain;
u32 seclen;
int err = security_secid_to_secctx(current_sid(), &domain, &seclen);
if (err) {
return false;
}
return strncmp(KERNEL_SU_DOMAIN, domain, seclen) == 0;
}

bool is_zygote(void *sec)
Expand Down
Loading