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()
555 struct cred *new = bprm->cred; in bprm_caps_from_vfs_caps() local
573 new->cap_permitted.cap[i] = in bprm_caps_from_vfs_caps()
574 (new->cap_bset.cap[i] & permitted) | in bprm_caps_from_vfs_caps()
575 (new->cap_inheritable.cap[i] & inheritable); in bprm_caps_from_vfs_caps()
577 if (permitted & ~new->cap_permitted.cap[i]) in bprm_caps_from_vfs_caps()
741 struct cred *new = bprm->cred; in handle_privileged_root() local
750 if (has_fcap && __is_suid(root_uid, new)) { in handle_privileged_root()
759 if (__is_eff(root_uid, new) || __is_real(root_uid, new)) { in handle_privileged_root()
761 new->cap_permitted = cap_combine(old->cap_bset, in handle_privileged_root()
767 if (__is_eff(root_uid, new)) in handle_privileged_root()
778 static inline bool __is_setuid(struct cred *new, const struct cred *old) in __is_setuid() argument
779 { return !uid_eq(new->euid, old->uid); } in __is_setuid()
781 static inline bool __is_setgid(struct cred *new, const struct cred *old) in __is_setgid() argument
782 { return !gid_eq(new->egid, old->gid); } in __is_setgid()
801 static inline bool nonroot_raised_pE(struct cred *new, const struct cred *old, in nonroot_raised_pE() argument
806 if ((__cap_grew(effective, ambient, new) && in nonroot_raised_pE()
807 !(__cap_full(effective, new) && in nonroot_raised_pE()
808 (__is_eff(root, new) || __is_real(root, new)) && in nonroot_raised_pE()
811 __is_suid(root, new) && in nonroot_raised_pE()
812 !__cap_full(effective, new)) || in nonroot_raised_pE()
813 (!__is_setuid(new, old) && in nonroot_raised_pE()
815 __cap_gained(permitted, new, old)) || in nonroot_raised_pE()
816 __cap_gained(ambient, new, old)))) in nonroot_raised_pE()
836 struct cred *new = bprm->cred; in cap_bprm_creds_from_file() local
848 root_uid = make_kuid(new->user_ns, 0); in cap_bprm_creds_from_file()
853 if (__cap_gained(permitted, new, old)) in cap_bprm_creds_from_file()
861 is_setid = __is_setuid(new, old) || __is_setgid(new, old); in cap_bprm_creds_from_file()
863 if ((is_setid || __cap_gained(permitted, new, old)) && in cap_bprm_creds_from_file()
865 !ptracer_capable(current, new->user_ns))) { in cap_bprm_creds_from_file()
867 if (!ns_capable(new->user_ns, CAP_SETUID) || in cap_bprm_creds_from_file()
869 new->euid = new->uid; in cap_bprm_creds_from_file()
870 new->egid = new->gid; in cap_bprm_creds_from_file()
872 new->cap_permitted = cap_intersect(new->cap_permitted, in cap_bprm_creds_from_file()
876 new->suid = new->fsuid = new->euid; in cap_bprm_creds_from_file()
877 new->sgid = new->fsgid = new->egid; in cap_bprm_creds_from_file()
881 cap_clear(new->cap_ambient); in cap_bprm_creds_from_file()
887 new->cap_permitted = cap_combine(new->cap_permitted, new->cap_ambient); in cap_bprm_creds_from_file()
894 new->cap_effective = new->cap_permitted; in cap_bprm_creds_from_file()
896 new->cap_effective = new->cap_ambient; in cap_bprm_creds_from_file()
898 if (WARN_ON(!cap_ambient_invariant_ok(new))) in cap_bprm_creds_from_file()
901 if (nonroot_raised_pE(new, old, root_uid, has_fcap)) { in cap_bprm_creds_from_file()
902 ret = audit_log_bprm_fcaps(bprm, new, old); in cap_bprm_creds_from_file()
907 new->securebits &= ~issecure_mask(SECURE_KEEP_CAPS); in cap_bprm_creds_from_file()
909 if (WARN_ON(!cap_ambient_invariant_ok(new))) in cap_bprm_creds_from_file()
914 (!__is_real(root_uid, new) && in cap_bprm_creds_from_file()
916 __cap_grew(permitted, ambient, new)))) in cap_bprm_creds_from_file()
1022 static inline void cap_emulate_setxuid(struct cred *new, const struct cred *old) in cap_emulate_setxuid() argument
1029 (!uid_eq(new->uid, root_uid) && in cap_emulate_setxuid()
1030 !uid_eq(new->euid, root_uid) && in cap_emulate_setxuid()
1031 !uid_eq(new->suid, root_uid))) { in cap_emulate_setxuid()
1033 cap_clear(new->cap_permitted); in cap_emulate_setxuid()
1034 cap_clear(new->cap_effective); in cap_emulate_setxuid()
1042 cap_clear(new->cap_ambient); in cap_emulate_setxuid()
1044 if (uid_eq(old->euid, root_uid) && !uid_eq(new->euid, root_uid)) in cap_emulate_setxuid()
1045 cap_clear(new->cap_effective); in cap_emulate_setxuid()
1046 if (!uid_eq(old->euid, root_uid) && uid_eq(new->euid, root_uid)) in cap_emulate_setxuid()
1047 new->cap_effective = new->cap_permitted; in cap_emulate_setxuid()
1059 int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags) in cap_task_fix_setuid() argument
1068 cap_emulate_setxuid(new, old); in cap_task_fix_setuid()
1080 if (uid_eq(old->fsuid, root_uid) && !uid_eq(new->fsuid, root_uid)) in cap_task_fix_setuid()
1081 new->cap_effective = in cap_task_fix_setuid()
1082 cap_drop_fs_set(new->cap_effective); in cap_task_fix_setuid()
1084 if (!uid_eq(old->fsuid, root_uid) && uid_eq(new->fsuid, root_uid)) in cap_task_fix_setuid()
1085 new->cap_effective = in cap_task_fix_setuid()
1086 cap_raise_fs_set(new->cap_effective, in cap_task_fix_setuid()
1087 new->cap_permitted); in cap_task_fix_setuid()
1166 struct cred *new; in cap_prctl_drop() local
1173 new = prepare_creds(); in cap_prctl_drop()
1174 if (!new) in cap_prctl_drop()
1176 cap_lower(new->cap_bset, cap); in cap_prctl_drop()
1177 return commit_creds(new); in cap_prctl_drop()
1196 struct cred *new; in cap_task_prctl() local
1246 new = prepare_creds(); in cap_task_prctl()
1247 if (!new) in cap_task_prctl()
1249 new->securebits = arg2; in cap_task_prctl()
1250 return commit_creds(new); in cap_task_prctl()
1264 new = prepare_creds(); in cap_task_prctl()
1265 if (!new) in cap_task_prctl()
1268 new->securebits |= issecure_mask(SECURE_KEEP_CAPS); in cap_task_prctl()
1270 new->securebits &= ~issecure_mask(SECURE_KEEP_CAPS); in cap_task_prctl()
1271 return commit_creds(new); in cap_task_prctl()
1278 new = prepare_creds(); in cap_task_prctl()
1279 if (!new) in cap_task_prctl()
1281 cap_clear(new->cap_ambient); in cap_task_prctl()
1282 return commit_creds(new); in cap_task_prctl()
1301 new = prepare_creds(); in cap_task_prctl()
1302 if (!new) in cap_task_prctl()
1305 cap_raise(new->cap_ambient, arg3); in cap_task_prctl()
1307 cap_lower(new->cap_ambient, arg3); in cap_task_prctl()
1308 return commit_creds(new); in cap_task_prctl()