kernel: use uid instead of package to compare allowlist, fix #580
This commit is contained in:
@@ -80,7 +80,7 @@ static void ksu_grant_root_to_shell()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool ksu_get_app_profile(struct app_profile *profile, bool query_by_uid)
|
bool ksu_get_app_profile(struct app_profile *profile)
|
||||||
{
|
{
|
||||||
struct perm_data *p = NULL;
|
struct perm_data *p = NULL;
|
||||||
struct list_head *pos = NULL;
|
struct list_head *pos = NULL;
|
||||||
@@ -88,10 +88,8 @@ bool ksu_get_app_profile(struct app_profile *profile, bool query_by_uid)
|
|||||||
|
|
||||||
list_for_each (pos, &allow_list) {
|
list_for_each (pos, &allow_list) {
|
||||||
p = list_entry(pos, struct perm_data, list);
|
p = list_entry(pos, struct perm_data, list);
|
||||||
bool uid_match =
|
bool uid_match = profile->current_uid == p->profile.current_uid;
|
||||||
(query_by_uid &&
|
if (uid_match) {
|
||||||
profile->current_uid == p->profile.current_uid);
|
|
||||||
if (uid_match || !strcmp(profile->key, p->profile.key)) {
|
|
||||||
// found it, override it with ours
|
// found it, override it with ours
|
||||||
memcpy(profile, &p->profile, sizeof(*profile));
|
memcpy(profile, &p->profile, sizeof(*profile));
|
||||||
found = true;
|
found = true;
|
||||||
@@ -183,7 +181,7 @@ bool ksu_is_allow_uid(uid_t uid)
|
|||||||
bool ksu_is_uid_should_umount(uid_t uid)
|
bool ksu_is_uid_should_umount(uid_t uid)
|
||||||
{
|
{
|
||||||
struct app_profile profile = { .current_uid = uid };
|
struct app_profile profile = { .current_uid = uid };
|
||||||
bool found = ksu_get_app_profile(&profile, true);
|
bool found = ksu_get_app_profile(&profile);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// no app profile found, it must be non root app
|
// no app profile found, it must be non root app
|
||||||
return default_non_root_profile.umount_modules;
|
return default_non_root_profile.umount_modules;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ bool ksu_get_allow_list(int *array, int *length, bool allow);
|
|||||||
|
|
||||||
void ksu_prune_allowlist(bool (*is_uid_exist)(uid_t, void *), void *data);
|
void ksu_prune_allowlist(bool (*is_uid_exist)(uid_t, void *), void *data);
|
||||||
|
|
||||||
bool ksu_get_app_profile(struct app_profile *, bool query_by_uid);
|
bool ksu_get_app_profile(struct app_profile *);
|
||||||
bool ksu_set_app_profile(struct app_profile *, bool persist);
|
bool ksu_set_app_profile(struct app_profile *, bool persist);
|
||||||
|
|
||||||
bool ksu_is_uid_should_umount(uid_t uid);
|
bool ksu_is_uid_should_umount(uid_t uid);
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = ksu_get_app_profile(&profile, false);
|
bool success = ksu_get_app_profile(&profile);
|
||||||
if (success) {
|
if (success) {
|
||||||
if (copy_to_user(arg3, &profile, sizeof(profile))) {
|
if (copy_to_user(arg3, &profile, sizeof(profile))) {
|
||||||
pr_err("copy profile failed\n");
|
pr_err("copy profile failed\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user