Lines Matching refs:new

241 int cap_capset(struct cred *new,  in cap_capset()  argument
268 new->cap_effective = *effective; in cap_capset()
269 new->cap_inheritable = *inheritable; in cap_capset()
270 new->cap_permitted = *permitted; in cap_capset()
276 new->cap_ambient = cap_intersect(new->cap_ambient, in cap_capset()
279 if (WARN_ON(!cap_ambient_invariant_ok(new))) in cap_capset()
594 struct cred *new = bprm->cred; in bprm_caps_from_vfs_caps() local
612 new->cap_permitted.cap[i] = in bprm_caps_from_vfs_caps()
613 (new->cap_bset.cap[i] & permitted) | in bprm_caps_from_vfs_caps()
614 (new->cap_inheritable.cap[i] & inheritable); in bprm_caps_from_vfs_caps()
616 if (permitted & ~new->cap_permitted.cap[i]) in bprm_caps_from_vfs_caps()
795 struct cred *new = bprm->cred; in handle_privileged_root() local
804 if (has_fcap && __is_suid(root_uid, new)) { in handle_privileged_root()
813 if (__is_eff(root_uid, new) || __is_real(root_uid, new)) { in handle_privileged_root()
815 new->cap_permitted = cap_combine(old->cap_bset, in handle_privileged_root()
821 if (__is_eff(root_uid, new)) in handle_privileged_root()
832 static inline bool __is_setuid(struct cred *new, const struct cred *old) in __is_setuid() argument
833 { return !uid_eq(new->euid, old->uid); } in __is_setuid()
835 static inline bool __is_setgid(struct cred *new, const struct cred *old) in __is_setgid() argument
836 { return !gid_eq(new->egid, old->gid); } in __is_setgid()
855 static inline bool nonroot_raised_pE(struct cred *new, const struct cred *old, in nonroot_raised_pE() argument
860 if ((__cap_grew(effective, ambient, new) && in nonroot_raised_pE()
861 !(__cap_full(effective, new) && in nonroot_raised_pE()
862 (__is_eff(root, new) || __is_real(root, new)) && in nonroot_raised_pE()
865 __is_suid(root, new) && in nonroot_raised_pE()
866 !__cap_full(effective, new)) || in nonroot_raised_pE()
867 (!__is_setuid(new, old) && in nonroot_raised_pE()
869 __cap_gained(permitted, new, old)) || in nonroot_raised_pE()
870 __cap_gained(ambient, new, old)))) in nonroot_raised_pE()
892 struct cred *new = bprm->cred; in cap_bprm_creds_from_file() local
904 root_uid = make_kuid(new->user_ns, 0); in cap_bprm_creds_from_file()
909 if (__cap_gained(permitted, new, old)) in cap_bprm_creds_from_file()
917 is_setid = __is_setuid(new, old) || __is_setgid(new, old); in cap_bprm_creds_from_file()
919 if ((is_setid || __cap_gained(permitted, new, old)) && in cap_bprm_creds_from_file()
921 !ptracer_capable(current, new->user_ns))) { in cap_bprm_creds_from_file()
923 if (!ns_capable(new->user_ns, CAP_SETUID) || in cap_bprm_creds_from_file()
925 new->euid = new->uid; in cap_bprm_creds_from_file()
926 new->egid = new->gid; in cap_bprm_creds_from_file()
928 new->cap_permitted = cap_intersect(new->cap_permitted, in cap_bprm_creds_from_file()
932 new->suid = new->fsuid = new->euid; in cap_bprm_creds_from_file()
933 new->sgid = new->fsgid = new->egid; in cap_bprm_creds_from_file()
937 cap_clear(new->cap_ambient); in cap_bprm_creds_from_file()
943 new->cap_permitted = cap_combine(new->cap_permitted, new->cap_ambient); in cap_bprm_creds_from_file()
950 new->cap_effective = new->cap_permitted; in cap_bprm_creds_from_file()
952 new->cap_effective = new->cap_ambient; in cap_bprm_creds_from_file()
954 if (WARN_ON(!cap_ambient_invariant_ok(new))) in cap_bprm_creds_from_file()
957 if (nonroot_raised_pE(new, old, root_uid, has_fcap)) { in cap_bprm_creds_from_file()
958 ret = audit_log_bprm_fcaps(bprm, new, old); in cap_bprm_creds_from_file()
963 new->securebits &= ~issecure_mask(SECURE_KEEP_CAPS); in cap_bprm_creds_from_file()
965 if (WARN_ON(!cap_ambient_invariant_ok(new))) in cap_bprm_creds_from_file()
970 (!__is_real(root_uid, new) && in cap_bprm_creds_from_file()
972 __cap_grew(permitted, ambient, new)))) in cap_bprm_creds_from_file()
1087 static inline void cap_emulate_setxuid(struct cred *new, const struct cred *old) in cap_emulate_setxuid() argument
1094 (!uid_eq(new->uid, root_uid) && in cap_emulate_setxuid()
1095 !uid_eq(new->euid, root_uid) && in cap_emulate_setxuid()
1096 !uid_eq(new->suid, root_uid))) { in cap_emulate_setxuid()
1098 cap_clear(new->cap_permitted); in cap_emulate_setxuid()
1099 cap_clear(new->cap_effective); in cap_emulate_setxuid()
1107 cap_clear(new->cap_ambient); in cap_emulate_setxuid()
1109 if (uid_eq(old->euid, root_uid) && !uid_eq(new->euid, root_uid)) in cap_emulate_setxuid()
1110 cap_clear(new->cap_effective); in cap_emulate_setxuid()
1111 if (!uid_eq(old->euid, root_uid) && uid_eq(new->euid, root_uid)) in cap_emulate_setxuid()
1112 new->cap_effective = new->cap_permitted; in cap_emulate_setxuid()
1126 int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags) in cap_task_fix_setuid() argument
1135 cap_emulate_setxuid(new, old); in cap_task_fix_setuid()
1147 if (uid_eq(old->fsuid, root_uid) && !uid_eq(new->fsuid, root_uid)) in cap_task_fix_setuid()
1148 new->cap_effective = in cap_task_fix_setuid()
1149 cap_drop_fs_set(new->cap_effective); in cap_task_fix_setuid()
1151 if (!uid_eq(old->fsuid, root_uid) && uid_eq(new->fsuid, root_uid)) in cap_task_fix_setuid()
1152 new->cap_effective = in cap_task_fix_setuid()
1153 cap_raise_fs_set(new->cap_effective, in cap_task_fix_setuid()
1154 new->cap_permitted); in cap_task_fix_setuid()
1239 struct cred *new; in cap_prctl_drop() local
1246 new = prepare_creds(); in cap_prctl_drop()
1247 if (!new) in cap_prctl_drop()
1249 cap_lower(new->cap_bset, cap); in cap_prctl_drop()
1250 return commit_creds(new); in cap_prctl_drop()
1272 struct cred *new; in cap_task_prctl() local
1322 new = prepare_creds(); in cap_task_prctl()
1323 if (!new) in cap_task_prctl()
1325 new->securebits = arg2; in cap_task_prctl()
1326 return commit_creds(new); in cap_task_prctl()
1340 new = prepare_creds(); in cap_task_prctl()
1341 if (!new) in cap_task_prctl()
1344 new->securebits |= issecure_mask(SECURE_KEEP_CAPS); in cap_task_prctl()
1346 new->securebits &= ~issecure_mask(SECURE_KEEP_CAPS); in cap_task_prctl()
1347 return commit_creds(new); in cap_task_prctl()
1354 new = prepare_creds(); in cap_task_prctl()
1355 if (!new) in cap_task_prctl()
1357 cap_clear(new->cap_ambient); in cap_task_prctl()
1358 return commit_creds(new); in cap_task_prctl()
1377 new = prepare_creds(); in cap_task_prctl()
1378 if (!new) in cap_task_prctl()
1381 cap_raise(new->cap_ambient, arg3); in cap_task_prctl()
1383 cap_lower(new->cap_ambient, arg3); in cap_task_prctl()
1384 return commit_creds(new); in cap_task_prctl()