diff options
Diffstat (limited to 'kernel/cred.c')
-rw-r--r-- | kernel/cred.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/kernel/cred.c b/kernel/cred.c index 7a0d80669886..eddc5e2e9587 100644 --- a/kernel/cred.c +++ b/kernel/cred.c | |||
@@ -49,6 +49,14 @@ struct cred init_cred = { | |||
49 | .subscribers = ATOMIC_INIT(2), | 49 | .subscribers = ATOMIC_INIT(2), |
50 | .magic = CRED_MAGIC, | 50 | .magic = CRED_MAGIC, |
51 | #endif | 51 | #endif |
52 | .uid = GLOBAL_ROOT_UID, | ||
53 | .gid = GLOBAL_ROOT_GID, | ||
54 | .suid = GLOBAL_ROOT_UID, | ||
55 | .sgid = GLOBAL_ROOT_GID, | ||
56 | .euid = GLOBAL_ROOT_UID, | ||
57 | .egid = GLOBAL_ROOT_GID, | ||
58 | .fsuid = GLOBAL_ROOT_UID, | ||
59 | .fsgid = GLOBAL_ROOT_GID, | ||
52 | .securebits = SECUREBITS_DEFAULT, | 60 | .securebits = SECUREBITS_DEFAULT, |
53 | .cap_inheritable = CAP_EMPTY_SET, | 61 | .cap_inheritable = CAP_EMPTY_SET, |
54 | .cap_permitted = CAP_FULL_SET, | 62 | .cap_permitted = CAP_FULL_SET, |
@@ -488,10 +496,10 @@ int commit_creds(struct cred *new) | |||
488 | get_cred(new); /* we will require a ref for the subj creds too */ | 496 | get_cred(new); /* we will require a ref for the subj creds too */ |
489 | 497 | ||
490 | /* dumpability changes */ | 498 | /* dumpability changes */ |
491 | if (old->euid != new->euid || | 499 | if (!uid_eq(old->euid, new->euid) || |
492 | old->egid != new->egid || | 500 | !gid_eq(old->egid, new->egid) || |
493 | old->fsuid != new->fsuid || | 501 | !uid_eq(old->fsuid, new->fsuid) || |
494 | old->fsgid != new->fsgid || | 502 | !gid_eq(old->fsgid, new->fsgid) || |
495 | !cap_issubset(new->cap_permitted, old->cap_permitted)) { | 503 | !cap_issubset(new->cap_permitted, old->cap_permitted)) { |
496 | if (task->mm) | 504 | if (task->mm) |
497 | set_dumpable(task->mm, suid_dumpable); | 505 | set_dumpable(task->mm, suid_dumpable); |
@@ -500,9 +508,9 @@ int commit_creds(struct cred *new) | |||
500 | } | 508 | } |
501 | 509 | ||
502 | /* alter the thread keyring */ | 510 | /* alter the thread keyring */ |
503 | if (new->fsuid != old->fsuid) | 511 | if (!uid_eq(new->fsuid, old->fsuid)) |
504 | key_fsuid_changed(task); | 512 | key_fsuid_changed(task); |
505 | if (new->fsgid != old->fsgid) | 513 | if (!gid_eq(new->fsgid, old->fsgid)) |
506 | key_fsgid_changed(task); | 514 | key_fsgid_changed(task); |
507 | 515 | ||
508 | /* do it | 516 | /* do it |
@@ -519,16 +527,16 @@ int commit_creds(struct cred *new) | |||
519 | alter_cred_subscribers(old, -2); | 527 | alter_cred_subscribers(old, -2); |
520 | 528 | ||
521 | /* send notifications */ | 529 | /* send notifications */ |
522 | if (new->uid != old->uid || | 530 | if (!uid_eq(new->uid, old->uid) || |
523 | new->euid != old->euid || | 531 | !uid_eq(new->euid, old->euid) || |
524 | new->suid != old->suid || | 532 | !uid_eq(new->suid, old->suid) || |
525 | new->fsuid != old->fsuid) | 533 | !uid_eq(new->fsuid, old->fsuid)) |
526 | proc_id_connector(task, PROC_EVENT_UID); | 534 | proc_id_connector(task, PROC_EVENT_UID); |
527 | 535 | ||
528 | if (new->gid != old->gid || | 536 | if (!gid_eq(new->gid, old->gid) || |
529 | new->egid != old->egid || | 537 | !gid_eq(new->egid, old->egid) || |
530 | new->sgid != old->sgid || | 538 | !gid_eq(new->sgid, old->sgid) || |
531 | new->fsgid != old->fsgid) | 539 | !gid_eq(new->fsgid, old->fsgid)) |
532 | proc_id_connector(task, PROC_EVENT_GID); | 540 | proc_id_connector(task, PROC_EVENT_GID); |
533 | 541 | ||
534 | /* release the old obj and subj refs both */ | 542 | /* release the old obj and subj refs both */ |