Repository navigation
Releases
Releases · tamnd/rukernel
v0.5.28
Added
- AppArmor checks the sockets, as net.c and af_inet.c of the Ubuntu kernel: a create, a bind, a connect, a listen, an accept, a send, a receive,
getsockname,getpeername,getsockopt,setsockoptandshutdownneed a network rule for the family and the type of the socket. For IPv4 and IPv6, a rule can also name the protocol, the addresses and the ports, the option and the backlog. A denial givesEACCESand a record of the classnet(#540). - AppArmor checks the creation of a user namespace, as task.c and lsm.c of the Ubuntu kernel. A profile with
usernsrules needs a rule that allows it, and a rule can give the label of the task in the new namespace. The new fileskernel.apparmor_restrict_unprivileged_userns,_forceand_complainof/proc/syswork as on Ubuntu: with the first at 1, anunconfinedtask withoutCAP_SYS_ADMINgoes to the profileunprivileged_userns, or getsEACCESif that profile is not there. A denial givesEACCESand a record of the classnamespace. A security module can now give files of/proc/sys(#540).
Fixed
- A read end of a FIFO gives
POLLHUPinpollonly after a writer opened after the end and closed, aspipe_pollof Linux. Before, a reader that waited inselectfor the first writer woke at once (#540). - A tmpfs mount with
size=N%takes N percent of the memory as its limit, asshmem_parse_oneof Linux, andsize=0has no limit. Before this, a size in percent had no limit, sostatfsgave 0 free blocks, and systemd refuseddaemon-reloadbecause /run had less than 16 MiB free. systemd mounts /run withsize=20%(#538).
v0.5.27
Added
- AppArmor checks
ptrace, as task.c of Linux: an attach and aPTRACE_TRACEMEneed the ptrace rules of the tracer and of the tracee. A profile without ptrace rules needsCAP_SYS_PTRACEto trace a task with another label. An exec of a traced task changes the label only if the tracer can trace the new label, asmay_change_ptraced_domainof Linux. A denial givesEACCESand a record of the classptrace(#540). - The objects
ct helper,ct timeout,ct expectationandsynproxyof nf_tables, as nft_ct.c and nft_synproxy.c of Linux, with the checks of Linux and their dumps, and thectkeyhelper. The objects do not change the packets yet: the connections of rk have no helpers, no timeouts of their own and no expectations, and rk has no SYN proxy. The dump of a rule now gives the name of its object with a NUL byte, as Linux. Before,ct expectation set "ctexpect"came back with a wrong byte at the end of the name (#542). - The boot test
cryptenrollon x86-64 and arm64, with a TPM. cryptsetup makes a LUKS2 image in a file, systemd-cryptenroll adds a key slot that the TPM seals to PCR 7, and cryptsetup opens the key slot with the token of the TPM only. libcryptsetup uses theskciphersockets ofAF_ALGfor the key slots. tools/systemd/build.sh adds cryptsetup, systemd-cryptenroll and tpm2-tools to the tree. WithRK_TPM=1, thesystemdboot test printssystemd-analyze has-tpm2, and with the full TPM2 support of systemd (a boot with EFI) it compares the PCRs ofsystemd-analyze pcrswith the PCRs of tpm2_pcrread.RK_RELEASE=1makes the boot tests use the release kernel, which unpacks the initramfs of the systemd tree much faster on a host without KVM (#541). snatanddnatto a prefix of nf_tables (snat ip prefix to ip saddr map { 10.141.11.0/24 : 192.168.2.0/24 }), asNF_NAT_RANGE_NETMAPof nft_nat.c of Linux. The address keeps the bits that are not in the prefix (#542).
v0.5.26
Added
- A socket has the owner and the mode of its inode, as sockfs of Linux. A new socket has the file system user and group IDs of the process and the mode 0777.
fchown,fchmodandfchownatwithAT_EMPTY_PATHchange them. After the release of the socket, a change of the owner givesENOENT, assockfs_setattrof Linux for CVE-2019-8912. LTP af_alg07 tests this (#541). - AppArmor checks the capabilities, as capability.c of Linux. A capability that the profile does not allow gives
EPERMand a record of the classcap, with the rulesauditandquietand the skip of a repeated record. Each check of a capability calls thecapablehook of the security modules after the check of the capability module, also the checks in a user namespace and the checks of a file, asns_capableandcapable_wrt_inode_uidgidof Linux (#540). - AppArmor checks the signals, as ipc.c of Linux. The rules of the sender must allow the send to the label of the target, and the rules of the target must allow the receive from the label of the sender. A denial gives
EACCESand a record of the classsignal. The match of the label of the other task,aa_label_matchof Linux, is in the new modulelabel(#540).
Fixed
- AppArmor finds the parent of a hat that has the name of a program, as
aa_split_fqnameof Linux. InP///bin/xthe parent isPand the hat is/bin/x. Before, the parent wasP/, so achange_hatfrom that hat to a sibling hat gaveECHILD(#540).
v0.5.25
Added
- The
AF_ALGsockets with the typeskcipher, as crypto/algif_skcipher.c of Linux, forecb(aes),cbc(aes),ctr(aes)andxts(aes)ofrk-crypto. Asendmsggives the operation withALG_SET_OPand the IV withALG_SET_IVin control messages, and adds the data to the queue. Arecvencrypts or decrypts the data of the queue in blocks. WithMSG_MORE, the operation continues in the nextsend, and the IV goes from onerecvto the next. libcryptsetup uses these sockets to open a LUKS2 key slot without dm-crypt (#541). - The
getdentscall of x86_64, with the records of the old formatlinux_dirent, asfilldirof Linux. Thereaddirtest of the AppArmor regression tests uses it (#540). - AppArmor checks the path operations, as the path hooks of lsm.c of Linux: a create, a
mkdir, amknod, a symbolic link, a hard link, a rename, anunlink, anrmdir, a truncate, achmod, achownand astat. The VFS has the hookspath_*,inode_getattrandfile_truncateof Linux, at the places where Linux calls them (#540). - The expressions
numgenandhashof nf_tables, as nft_numgen.c and nft_hash.c of Linux, and more keys ofmeta, as nft_meta.c:priority,pkttype,cpu,iifgroup,oifgroup,random,iifkind,oifkind,time,day,hour,sdifandsdifname. A rule setsmeta priorityandmeta pkttypetoo. A packet now has a priority and a type, asskb->priorityandskb->pkt_type.meta iifandmeta iifnameof a packet with no device give 0 and "", as in Linux (#542). - The expression
payloadof nf_tables writes the packet, asnft_payload_set_evalof Linux, with the checksums of IP, of the transport header and of SCTP. The expressionqueue, as nft_queue.c of Linux, gives the packet to its queue (#542).
v0.5.24
Added
- fanotify has
FAN_REPORT_MNT. A group with this flag marks a mount namespace withFAN_MARK_MNTNSand getsFAN_MNT_ATTACHandFAN_MNT_DETACHwhen a mount of the namespace is attached, moved or unmounted. Each event has aFAN_EVENT_INFO_TYPE_MNTrecord with the unique mount ID, and the errors and the record layout are the same as in Linux. Theinitboot test checks the errors, the fdinfo line and the events of mount, move and umount. (#539) - The
sdbpfboot test runs the unit tests test-bpf-devices, test-bpf-firewall and test-bpf-foreign-programs of systemd. They attach cgroup programs withBPF_PROG_ATTACH,BPF_PROG_DETACH,BPF_PROG_QUERYandBPF_LINK_CREATE, and all three pass.RK_SYSTEMD_PACKAGESof tools/systemd/build.sh adds packages to the systemd tree, and this test needssystemd-testsandiputils-ping(#537).
Fixed
NFT_MSG_GETSETELEMof nf_tables in a set withNFT_SET_INTERVALgives the range that has the key, as thegetoperations of nft_set_rbtree.c and nft_set_pipapo.c of Linux. Before this change, it gaveENOENTfor a key that is not the start or the end of a range (#542).- A range of a set with a key of more than one field matches a key that is in the range in each field, as nft_set_pipapo.c of Linux. Before this change, the key was compared as one number (#542).
- A new element of a set of nf_tables with
NFT_SET_INTERVALthat overlaps a range of the set givesEEXIST, as__nft_rbtree_insertandnft_pipapo_insertof Linux. The add of an element no longer looks at all of the elements of a set with no timeouts, so that a batch of 65000 ranges does not take minutes (#542). - A range of a set of nf_tables that starts where the range before it ends matches its keys. Before this change, the start and the end at the same key were in the wrong order, and the two ranges did not match (#542).
- The dump of a set of nf_tables with ranges of keys of more than one field gives the elements in the order of their inserts, as
nft_pipapo_walkof Linux. Before this change, the elements were in the order of their keys (#542). - A set of nf_tables with ranges of keys of more than one field takes a range again when a later range also has its first key, as
nft_pipapo_insertof Linux. Before this change, the set gaveEEXIST(#542).
v0.5.23
Added
- The eBPF verifier gives the result of kernel/bpf/verifier.c of Linux for all programs of bpf/test_verifier of the socket filter and cgroup program types. It prunes the paths with equal states at the jump targets and refuses a loop that does not end, it refines the bounds of a register after
BPF_JSETand after aBPF_JMP32that compares as 64 bits, and it checks the alignment of the pointers and the size of each context field as Linux, with the errors and the log messages of Linux in the same order.bpf(BPF_PROG_TEST_RUN)runs a program on a packet or a context from user space. The kselftest boot test runs bpf/test_verifier, and tools/kselftest/bpf.md gives the result: 281 passed and 0 failed (#537). - The stateful expressions of the sets of nf_tables, as
nft_set_elem_expr_allocof Linux:NFTA_SET_EXPRandNFTA_SET_EXPRESSIONSof a set,NFTA_SET_ELEM_EXPRandNFTA_SET_ELEM_EXPRESSIONSof an element, andNFTA_DYNSET_EXPRandNFTA_DYNSET_EXPRESSIONSofdynset. The expressions arecounter,quota,limitandconnlimit, two at most. Each element has its own state: a copy of the expressions of the set, or the ones that it gives with the same types. Alookupand adynsetrun the expressions of the element that they find. Theconnlimitexpression of nft_connlimit.c counts the connections that connection tracking still has (#542). - The
AF_ALGsockets with the typehash, as crypto/af_alg.c and crypto/algif_hash.c of Linux. A socket binds to a hash ofrk-cryptoby its name,setsockopt(SOL_ALG, ALG_SET_KEY)sets the key of an HMAC, andacceptgives a socket for one computation. AsendwithMSG_MOREadds data, and arecvgives the digest. Anaccepton the socket of a computation copies its state. As withcrypto.af_alg_restrict=1of Linux, a name that is not in the allow list givesENOENT, and a name that needs a capability givesENOENTwithoutCAP_SYS_ADMINorCAP_NET_ADMIN(#541).
v0.5.22
Added
- The crypto API in the new crate
rk-crypto, as crypto/ of Linux: the hashes SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512, the templatehmac, the block cipher AES, and the templatesecb,cbc,ctrandxtswith ciphertext stealing. The code is plain Rust. The unit tests use the vectors of crypto/testmgr.h of Linux (#541). - The event log of the firmware at
/sys/kernel/security/tpm0/binary_bios_measurements, as drivers/char/tpm/eventlog of Linux. The kernel copies the log area of the ACPITPM2table on x86-64, or the area oflinux,sml-baseandlinux,sml-sizeof the device tree node of the TPM on arm64. The file has the first event and each next event of the crypto agile format, up to the first event that is not valid, astpm2_binary_bios_measurements_showof Linux. On x86-64 thetpmboot test replays the log of SeaBIOS withtpm2_eventlog, and the SHA-256 PCRs of the log must be the PCRs oftpm2_pcrread(#541). - The flowtables of nf_tables, as nf_tables_api.c and nft_flow_offload.c of Linux:
NFT_MSG_NEWFLOWTABLE,NFT_MSG_GETFLOWTABLE,NFT_MSG_DELFLOWTABLEandNFT_MSG_DESTROYFLOWTABLE, with the ingress hook, the priority, the flags and the list of devices, and theflow_offloadexpression in the forward hook. A device can be in one flowtable of a table only (EEXIST), a flowtable that a rule uses cannot be deleted (EBUSY), and a device that goes away leaves the flowtable. The packets do not take a fast path:flow_offloaddoes not change them (#542). - AppArmor enforces the file rules of a profile in enforce mode, as file.c and domain.c of Linux. An open, a read, a write, a lock or a map that the rules do not allow gives
EACCESand aDENIEDrecord. So does an exec with no exec rule, an exec to a profile that is not there, and achange_profileor achange_onexecthat the rules do not allow. A profile in complain mode gives anALLOWEDrecord and the operation goes on, and a profile in kill mode also kills the task. Adenyrule denies in each mode (#540).
v0.5.21
Added
- AppArmor has child policy namespaces, as policy_ns.c of Linux. A load of a profile
:NS:NAME, or of a policy with the namespaceNS, makes the namespaceNSif it is not there, and the load records end withns="NS". The fileprofileslists these profiles as:NS:NAME, and a remove of:NS:NAMEor:NS:removes the profile or the namespace. Thusapparmor_parserloads all the profiles of Ubuntu 26.04, also:glycin:loadersand:glycin:bwrap, andaa-statuslists them. A task changes to a profile of a namespace withchange_profileorchange_onexecof:NS://NAME, asaa-exec --namespacedoes. The task sees the names of its namespace without the namespace, and the attach at exec looks in its namespace. A task can also put a profile on a stack with its label, withstack NAMEorchangeprofile &NAME, now or at the next exec. The label of the task is thenA//&B, and each profile of the stack checks the file accesses and changes at an exec. For a script, the exec hook of AppArmor now gets the script and not its interpreter, as on Linux, so the rules for the script give the profile andAT_SECURE. tools/apparmor runs the AppArmor regression tests in complain mode under QEMU, on rukernel and on a Linux reference kernel, and tools/apparmor/report.md compares the results (#540). /dev/tpmrm0(253:65536), the resource manager of TPM 2.0, as tpm2-space.c and tpmrm-dev.c of Linux. Each open file has a space with up to 3 transient objects and 3 sessions. Between two commands the driver saves their contexts and flushes the objects, and before the next command it loads them again. The objects get virtual handles, andTPM2_GetCapabilityfor the handles gives only the objects of the space. A command that the TPM does not have getsTPM_RC_COMMAND_CODEin the layer of the resource manager. The driver reads the attributes of the commands at boot./dev/tpm0and/dev/tpmrm0now take a new command after a read of a part of the response, giveEINVALfor a command that is shorter than its size field, and give the error of a nonblocking write in the next read, as Linux.tools/kselftest/build.shcopies the tpm2 kselftests,tools/tpm/build.shadds python3, and thetpmboot test runs test_smoke.sh, test_space.sh and test_async.sh (#541).
Fixed
- A kill of the processes of a cgroup with
memory.oom.groupcounts the victim again inoom_killofmemory.events, asoom_kill_memcg_memberof Linux kills each process of the group, the victim too. It also counts a process that is on its way out. Before, the count was one less than on Linux, andtest_memcg_oom_group_score_eventsof the cgroup kselftests failed (#536). - A cgroup that ran past its
cpu.maxquota stays throttled until the next periods pay for the difference, asdistribute_cfs_runtimeof Linux unthrottles a group only when its time is above 0. Its threads wait once, up to the end of the period that pays, and do not wake in each period, because the CPU time of such a wake also counts against the quota.throttled_useccounts the throttle up to the end of that period. Before, a thread waited only to the end of one period and then ran again, so a cgroup that ran past its quota got more CPU time than its quota over many periods (#536).
v0.5.20
Added
BPF_MAP_TYPE_PROG_ARRAYand the helperbpf_tail_call, as kernel/bpf/arraymap.c andJMP_TAIL_CALLof Linux. A system call writes the descriptor of a program to a slot and reads the ID of the program. All programs of an array and all programs that use it have one type. A tail call to an empty slot or to an index out of the array continues after the call, and a run does at most 33 tail calls. The last close of the array removes its programs. The verifier refuses a program array with another helper, a tail call with another map, and a tail call in a program with functions, with the messages of Linux. Theltpboot test also runs bpf_prog05, bpf_prog06 and bpf_prog07. They do not apply, as on Linux, because they dropCAP_BPFandkernel.unprivileged_bpf_disabledis 2 (#537)./dev/tpm0(10:224) for the TPM, as tpm-dev.c of Linux: one open file at a time, a write sends one command and a read gives its response./sys/class/tpm/tpm0hasdev,uevent,tpm_version_majorand the directorypcr-sha256with the digest of each PCR, from a new hook for the attributes of a class in sysfs.tools/tpm/build.shinstalls tpm2-tools from Alpine, and with it thetpmboot test runstpm2_getrandom 8andtpm2_pcrread sha256:0,7on/dev/tpm0and compares the PCRs withpcr-sha256(#541).
Fixed
- A write of
memory.peakstarts a new peak for the open file only, aspeak_writeof Linux. A read of that open file shows the largest use after the write, and the other readers ofmemory.peakstill see the largest use since the cgroup was made. Each other open file with a write gets the use now if it is larger than its value. Before, a write reset the peak of the cgroup for all readers, andtest_memcg_current_peakof the cgroup kselftests failed.memory.swap.peakstays 0, because rukernel has no swap (#536). - A populate of many pages in one system call, as
mlock,MAP_POPULATEandMAP_LOCKEDdo, waits formemory.highafter each batch of 64 pages, astry_charge_memcgof Linux callsmem_cgroup_handle_over_high. A kill stops the populate. Before, the wait came only at the return to user mode, so onemlockof 200 MB in a cgroup withmemory.high30M went up tomemory.maxat once, andtest_memcg_high_syncof the cgroup kselftests failed (#536). - tools/kselftest/build.sh builds the cgroup selftests without optimization, as their Makefile in Linux does. At -O2, gcc removed the memory use of
alloc_anonoftest_memcontrol, sotest_memcg_max,test_memcg_oom_eventsand thememory.oom.grouptests found no OOM kill (#536).
v0.5.19
Added
- The kselftest boot test runs
test_coreandtest_cpusetof the cgroup selftests. tools/kselftest/build.sh builds them with cgroup/lib/cgroup_util.c, and the init script of the test mounts cgroup2 at /sys/fs/cgroup withnsdelegate, as systemd mounts it (#536). - The kselftest boot test runs
test_freezerandtest_killof the cgroup selftests (#536). - A TPM 2.0 driver, rk-drv-tpm, as drivers/char/tpm of Linux. On x86-64 the kernel reads the address of the CRB from the ACPI
TPM2table, and on arm64 it finds the FIFO (TIS) interface at the device tree node withcompatible = "tcg,tpm-tis-mmio", also on a bus withranges. The CRB driver uses the locality, the ready and idle requests, the start and cancel registers and the command and response buffers. The TIS driver uses the locality, the status, the burst count and the data FIFO. Each step waits up to the TCG time limits, and each command up to its duration of Linux. At boot the driver starts the TPM astpm2_auto_startupof Linux. The newtpmboot test gives the machine a swtpm, and the kernel sendsTPM2_Startup,TPM2_GetRandomandTPM2_PCR_Readon x86-64 and on arm64 (#541).
Fixed
- A thread that a signal or a tracer stopped, or that waits for its
vforkchild, counts as frozen in its cgroup, ascgroup_enter_frozenindo_signal_stop,ptrace_stopandwait_for_vfork_doneof Linux. A thread that moves to another cgroup in such a wait moves its count. A stop of the group or a request ofPTRACE_INTERRUPTends the wait in the freezer, and the thread takes the stop, asJOBCTL_PENDING_MASKends the freezer trap of Linux. Before, a freeze of a cgroup with a stopped, traced orvforkthread did not end, andtest_freezerof the cgroup kselftests failed (#536). - A change of
cgroup.eventsand of the other files with events of cgroup2 sendsIN_MODIFYto the inotify marks of the file, askernfs_notifyof Linux. A write ofcgroup.freezein a cgroup that a cgroup above it keeps frozen also tells an event, ascgroup_freezeof Linux, so that a reader does not wait for a change that does not come (#536). - The scheduler does not call the notice function of rk-cgroup, because that function now sends inotify events, which must not run in the scheduler. As
kernfs_notifyof Linux defers its work, a change of a file with events that comes from a CPU charge waits for the next call outside the scheduler (#536). /proc/PID/task/TID/cgroupshows the cgroup of the threadTID, asproc_cgroup_showof Linux. In a threaded subtree, a thread can be in another cgroup than its process. Before, the file showed the cgroup of the process, andtest_cgcore_thread_migrationfailed (#536).