~/bend-docscommunity

exec.bend checks

raw source on the hub · import bend-osdev-caps@0.1.0.0/exec.bend as Exec

bend-osdev-caps, exec.bend: the transformation of a thread's capability sets during execve(2), as capabilities(7) documents it ("Transformation of capabilities during execve()", "Safety checking for capability-dumb binaries", "Capabilities and execution of programs by root") and execve(2) (set-user-ID, and when set-ID bits and file capabilities are ignored).

2 imports
import Base
import ./caps.bend as C

Types

type CapExecFlags source · line 13 · raw

Data

The file's sets as the transformation uses them (the notional all-ones sets of the root rules, or the file's own), the notional effective bit, and whether the file is privileged (set-user-ID, set-group-ID, or with capabilities).

Definitions

def CapExec.ambient source · line 16 · raw

@privileged:Bool -> @a:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapSet -> 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapSet

def CapExec.effective source · line 23 · raw

@effective:Bool -> @p:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapSet -> @a:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapSet -> 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapSet

def CapExec.sets source · line 37 · raw

@fl:CapExecFlags -> @s:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapState -> 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapState

capabilities(7): P'(ambient) = (file is privileged) ? 0 : P(ambient) P'(permitted) = (P(inheritable) & F(inheritable)) | (F(permitted) & P(bounding)) | P'(ambient) P'(effective) = F(effective) ? P'(permitted) : P'(ambient) P'(inheritable) = P(inheritable) P'(bounding) = P(bounding)

def CapExec.euid source · line 46 · raw

@ign:Bool -> @setuid:Bool -> @owner:U32 -> @euid:U32 -> U32

the effective user ID after execve: the file's owner if it is set-user-ID, unless set-ID bits are ignored

def CapExec.fcaps source · line 58 · raw

@ign:Bool -> @fc:Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets> -> Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets>

the file's capabilities, unless they are ignored

def CapExec.has_caps source · line 65 · raw

@fc:Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets> -> Bool

def CapExec.privileged source · line 73 · raw

@ign:Bool -> @setuid:Bool -> @setgid:Bool -> @fc:Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets> -> Bool

a privileged file: set-user-ID, set-group-ID, or with capabilities

def CapExec.flags.file source · line 82 · raw

@priv:Bool -> @effective:Bool -> @fc:Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets> -> CapExecFlags

the file's own sets (empty when it has none); effective is the notional effective bit of the root rules, ORed with the file's own

def CapExec.flags.suid_root source · line 91 · raw

@priv:Bool -> @fc:Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets> -> CapExecFlags

effective UID 0 but real UID not: the file's sets are all ones, unless the file has capabilities (a set-user-ID-root program with file capabilities)

def CapExec.fc_effective source · line 98 · raw

@fc:Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets> -> Bool

def CapExec.flags.go source · line 111 · raw

@noroot:Bool -> @r0:Bool -> @e0:Bool -> @priv:Bool -> @fc:Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets> -> CapExecFlags

"Capabilities and execution of programs by root": with r0 (real UID 0) and e0 (effective UID 0, after the set-user-ID bit), unless SECBIT_NOROOT: (1) the file's inheritable and permitted sets are all ones (but a set-user-ID-root program with capabilities run by a non-root real UID keeps its own); (2) if e0, the file effective bit is one.

def CapExec.file_caps source · line 128 · raw

@k:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapsKernel -> @f:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFile -> @ign:Bool -> Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets>

the file's capabilities as execve sees them: none if ign, or if the kernel has file capabilities off

def CapExec.flags.mk source · line 133 · raw

@+fc2:Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets> -> @c:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapCred -> @f:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFile -> @+ign:Bool -> CapExecFlags

def CapExec.flags source · line 138 · raw

@k:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapsKernel -> @c:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapCred -> @+f:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFile -> @+ign:Bool -> CapExecFlags

def Caps.execve.sets source · line 144 · raw

@k:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapsKernel -> @+c:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapCred -> @f:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFile -> @ign:Bool -> 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapState

The thread's sets after it executes f. ign: the set-user-ID and set-group-ID bits and the file capabilities are ignored (no_new_privs, a nosuid mount, or a ptraced caller: execve(2)).

def CapExec.dumb_ok source · line 149 · raw

@fc:Maybe<&2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFileSets> -> @p:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapSet -> Bool

"Safety checking for capability-dumb binaries": a file with capabilities and the effective bit must grant all of its permitted set

def CapExec.fin source · line 160 · raw

@ok:Bool -> @c:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapCred -> @+euid:U32 -> @s:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapState -> Result<&2, &2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapsError, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapCred>

def CapExec.new_euid source · line 169 · raw

@c:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapCred -> @f:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFile -> @ign:Bool -> U32

def Caps.execve source · line 177 · raw

@+k:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapsKernel -> @+c:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapCred -> @+f:0xaedcbedcbe1c3df31795343ff6f64678/caps.CapFile -> @+ign:Bool -> Result<&2, &2, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapsError, 0xaedcbedcbe1c3df31795343ff6f64678/caps.CapCred>

execve(2) of f: the new credentials (the effective user ID changes for a set-user-ID file, and the saved set-user-ID becomes the effective one), or CapsCapabilityDumb (EPERM)