Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\commoncap.c Create Date:2022-07-28 18:36:51
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:ap_bprm_set_creds - Set up the proposed credentials for execve().*@bprm: The execution parameters, including the proposed creds* Set up the proposed credentials for a new execution context being* constructed by execve()

Proto:int cap_bprm_set_creds(struct linux_binprm *bprm)

Type:int

Parameter:

TypeParameterName
struct linux_binprm *bprm
809  old = current_cred - Access the current task's subjective credentials* Access the subjective credentials of the current task. RCU-safe,* since nobody else can modify it.()
810  new = w credentials
811  effective = TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0. , has_fcap = TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0.
815  If WARN_ON(!cap_ambient_invariant_ok(old)) Then Return -EPERM
818  ret = Attempt to get the on-exec apply capability sets for an executable file from* its xattrs and, if present, apply them to the proposed credentials being* constructed by execve().
819  If ret < 0 Then Return ret
822  root_uid = make_kuid - Map a user-namespace uid pair into a kuid
824  handle_privileged_root - Handle case of privileged root*@bprm: The execution parameters, including the proposed creds*@has_fcap: Are any file capabilities set?*@effective: Do we have effective root privilege?*@root_uid: This namespace' root UID WRT
827  If __cap_gained(permitted, new, old) Then s to clear in current->personality |= Security-relevant compatibility flags that must be* cleared upon setuid or setgid exec:
835  is_setid = __is_setuid(new, old) || __is_setgid(new, old)
837  If (is_setid || __cap_gained(permitted, new, old)) && ( how unsafe this exec is (mask of LSM_UNSAFE_*) & ~LSM_UNSAFE_PTRACE || Not ptracer_capable - Determine if the ptracer holds CAP_SYS_PTRACE in the namespace*@tsk: The task that may be ptraced*@ns: The user namespace to search for CAP_SYS_PTRACE in* Return true if the task that is ptracing the current task had CAP_SYS_PTRACE ) Then
846  caps we're permitted = cap_intersect( caps we're permitted , caps we're permitted )
850  saved UID of the task = UID for VFS ops = effective UID of the task
851  saved GID of the task = GID for VFS ops = effective GID of the task
854  If has_fcap || is_setid Then cap_clear( Ambient capability set )
861  caps we're permitted = cap_combine( caps we're permitted , Ambient capability set )
867  If effective Then caps we can actually use = caps we're permitted
869  Else caps we can actually use = Ambient capability set
872  If WARN_ON(!cap_ambient_invariant_ok(new)) Then Return -EPERM
875  If 1) Audit candidate if current->cap_effective is set* We do not bother to audit if 3 things are true:* 1) cap_effective has all caps* 2) we became root *OR* are were already root* 3) root is supposed to have all caps (SECURE_NOROOT) Then
876  ret = audit_log_bprm_fcaps(bprm, new, old)
877  If ret < 0 Then Return ret
881  SUID-less security management &= ~Each securesetting is implemented using two bits. One bit specifieswhether the setting is on or off. The other bit specify whether thesetting is locked or not. A setting which is locked cannot bechanged from user-level. (When set, a process can retain its capabilities even aftertransitioning to a non-root user (the set-uid fixup suppressed bybit 2). Bit-4 is cleared when a process calls exec(); setting bothbit 4 and 5 will create a barrier through exec that no exec()'d)
883  If WARN_ON(!cap_ambient_invariant_ok(new)) Then Return -EPERM
887  cap_elevated = 0
888  If is_setid || Not __is_real(root_uid, new) && (effective || __cap_grew(permitted, ambient, new)) Then cap_elevated = 1
894  Return 0