Repository navigation
Description
Part of #14.
rukernel has no LSM framework. The permission checks are the capability and mode checks of rk_vfs::cred and seccomp. There is no securityfs, no /sys/kernel/security/lsm, no /proc/PID/attr, no lsm_* system call, and no Landlock or Yama. The security.* xattrs can be stored and read. LTP tests that read /sys/kernel/security/lsm take the path for a kernel with no LSM. spec/13-security.md section 13.2 has the scope.
Scope
- The LSM framework: a table of hooks with the names of include/linux/lsm_hook_defs.h, the security blobs on credentials, inodes, files, tasks, super blocks, sockets and IPC objects, the
lsm=boot parameter, and the capability module as the first LSM. Call the hooks at the same places as Linux. Test: all boot tests and LTP syscalls. Exit: no change in the results, and the bench entry rows stay in the noise. Add the LSM framework with the capability module #596, Give the super blocks and the System V IPC objects their security blobs #601: the framework, the blobs and the capability module;-- only lsmpasses on x86_64 and arm64. - securityfs at
/sys/kernel/securitywith the filelsm,/proc/PID/attrwithcurrent,execandprevand the directory of each module, and the system callslsm_get_self_attr,lsm_set_self_attrandlsm_list_modules. Add Yama withkernel.yama.ptrace_scope. Test: addlsmto tools/kselftest/build.sh and run lsm_get_self_attr_test, lsm_set_self_attr_test and lsm_list_modules_test. Exit: the three pass, and LTP ptrace* does not change. Add securityfs, the lsm_* system calls and /proc/PID/attr #604, Add Yama with kernel.yama.ptrace_scope, and the lsm kselftests #605: securityfs,/proc/PID/attr, thelsm_*system calls and Yama; the three lsm kselftests pass and LTP ptrace* does not change. - AppArmor, complain mode: a port of security/apparmor. The policy load, replace and remove through securityfs, the unpack of the binary policy, the DFA match on paths, the attach of a profile at
exec,change_profileandchange_hatthrough/proc/PID/attr, and the audit messages to the kernel log. Test:apparmor_parserloads the profiles of Ubuntu 26.04, andaa-statuslists them. Run the AppArmor regression tests (tests/regression/apparmor of the AppArmor project) in complain mode. Exit: the tests that check the load and the attach reach the pass set of the reference. Add the AppArmor module and its securityfs tree #657 Unpack the AppArmor binary policy and keep the profile tree #662 Attach the AppArmor profiles at exec and show the label in /proc/PID/attr #666 Check the open files with the AppArmor file rules #672 Let a task change its AppArmor label with change_hat and change_profile #677 AppArmor namespaces and stacks, and the regression tests in complain mode #693: rukernel passes the 5 load and attach tests and the 198 checks that pass on Linux 6.8 in complain mode. - AppArmor, enforce mode: a denial gives
EACCES, and the file, capability, network, unix socket, signal, ptrace and user namespace rules work. Test: the AppArmor regression tests, and a newubuntuboot test that boots Ubuntu 26.04 with AppArmor in enforce mode tomulti-user.target. Exit: the regression tests reach the pass set of the reference, and the boot test passes. apparmor: enforce mode for the file and exec rules #698 apparmor: the path hooks #710 apparmor: the capability rules #715 apparmor: the signal rules #716 apparmor: the ptrace rules #718 apparmor: the network rules #723 apparmor: the user namespace rules #725 apparmor: the mount rules #727 apparmor: the unix socket rules #728 apparmor: check the inherited files at exec #731 xtask: the ubuntu boot test, Ubuntu 26.04 with AppArmor in enforce mode #736: a denial givesEACCESfor each rule class, the regression tests reach the pass set of Linux 6.8 (usernsandnet_inetfail on Linux 6.8 too), and theubuntuboot test passes. - SELinux, permissive mode: a port of security/selinux. selinuxfs at
/sys/fs/selinux, the policy load, the security server and the AVC, the labels insecurity.selinuxon ext4, xfs and tmpfs, thefs_useandgenfsconrules, thecontext=mount options, and the label change atexec. Test: the targeted policy of Fedora 44 loads,getenforcegivesPermissive, andls -Zof the root file system gives the same labels as on the reference. Exit: the boot tomulti-user.targetlogs the same AVC denials as the reference. In progress: selinux: the binary policy, selinuxfs and the modes of SELinux #757 selinux: the security server, the AVC and the transaction files #787 selinux: the SIDs of the tasks, the exec transitions and /proc/PID/attr (#540) #790 selinux: the labels of the inodes from fs_use and genfscon, and security.selinux in getxattr (#540) #795 SELinux: check the access to files #799 SELinux: check the operations on the names of the directories #803 SELinux: the labels of new files and the changes of security.selinux #804 SELinux: the checks of the open files #805 SELinux: the ioctl commands and the extended permissions #812 SELinux: the checks of the maps of files and of anonymous memory #821 SELinux: the checks of the operations on other tasks #822 SELinux: the checks of the mounts #824 SELinux: the check of the capabilities #828: the crate and selinuxfs, the security server and the AVC, the SIDs of the tasks and the exec checks, the labels of the inodes fromfs_useandgenfscon, the checks of the access to files, the checks of the operations on the names of the directories, the labels of the new files and the changes ofsecurity.selinux, the checks of the open files, the checks of the ioctl commands with the extended permissions, the checks of the maps of files and of anonymous memory, the checks of the operations on other tasks, the checks of the mounts, and the check of the capabilities. - SELinux, enforcing mode: the network, netlink, IPC and BPF controls, and the netlink notices of policy loads. Test: the selinux-testsuite of the SELinuxProject, and a new
fedoraboot test that boots Fedora 44 with SELinux in enforcing mode tomulti-user.target. Run the systemd TEST-06-SELINUX integration test. Exit: the selinux-testsuite reaches the pass set of the reference, apart from the listed exceptions, and the boot test passes. - Audit: the protocol
NETLINK_AUDITwithAUDIT_GET,AUDIT_SET, the user messages, and the AVC and AppArmor records, as auditd and journald read them. Test: on thefedoraboot test,ausearch -m AVCshows a denial that the test makes. Exit: the record has the same fields as on the reference.
Done when
Ubuntu boots with AppArmor enforcing. Fedora boots with SELinux enforcing. This is the exit of the fifth item of #14.
Test each task on x86_64 and on arm64. Give the result of both in the PR body.
Linux reference: security/security.c, include/linux/lsm_hook_defs.h, security/inode.c, security/lsm_syscalls.c, security/apparmor/policy_unpack.c, security/selinux/hooks.c, security/selinux/ss/services.c, kernel/audit.c.
Activity
tamnd commentedon Nov 5, 2026
#596 is merged. It adds the LSM framework: the hook table with the names of Linux, the first error of the modules as
call_int_hook, the security blobs, the boot order withlsm=andsecurity=, the capability module first, and the hooks of the file, exec, task and socket paths. After the rebase on #594,Cred::capablechecksns_capablein the first user namespace and then calls thecapablehooks. Tests:cargo test -p rk-vfs --lib107 passed, and-- only lsmpassed on x86_64 and arm64 (-- only usernsalso passed on x86_64). Item 1 is ticked after the next PR, which gives the super blocks and the IPC objects their blobs.tamnd commentedon Nov 5, 2026
#601 is merged. The super blocks get their blob in
get_tree, and each message queue, semaphore set and shared memory segment has a security part with the alloc, free and associate hooks and theipc_permissionhook after the mode check. Tests:cargo test -p rk-vfs --lib108 passed, and-- only lsmpassed on x86_64 and arm64. Item 1 is now ticked. The next PR adds securityfs,/proc/PID/attrand thelsm_*system calls.tamnd commentedon Nov 5, 2026
#604 is merged. It adds securityfs at
/sys/kernel/securitywith the filelsm, the system callslsm_get_self_attr,lsm_set_self_attrandlsm_list_modules, and/proc/PID/attr. Tests: the rk-vfs unit tests passed, and-- only lsmpassed on x86_64 and arm64. With the LTP,lsm_get_self_attr02,lsm_list_modules01andlsm_list_modules02pass. The other three give TCONF until a module givesLSM_ATTR_CURRENT. Item 2 is not ticked yet: the next PR adds Yama and the lsm kselftests.tamnd commentedon Nov 5, 2026
#605 is merged. It adds Yama with
kernel.yama.ptrace_scope(0 to 3, and 3 stays) andPR_SET_PTRACER, and it adds the lsm tests to tools/kselftest/build.sh. Tests: lsm_get_self_attr_test 6/6, lsm_list_modules_test 5/5 and lsm_set_self_attr_test 4/4 pass. LTP ptrace01 to ptrace11: 9 pass, and ptrace04 and ptrace07 give TCONF, as in the baseline.-- only lsmpassed on x86_64 and arm64. Item 2 is now ticked. The next PR addsNETLINK_AUDIT(item 7, part 1).tamnd commentedon Nov 5, 2026
#613 is merged. It adds
NETLINK_AUDITwithAUDIT_GET,AUDIT_SETand the user messages (#540, item 7, part 1). The records go to auditd, or to the kernel log if auditd is not there, and a copy goes to the groupAUDIT_NLGRP_READLOG. Tests:cargo test -p rk-net --lib83 passed, and-- only auditpassed on x86_64 (with the bzImage and UEFI) and arm64, with 24 checks. Item 7 is not ticked: the AVC and AppArmor records need the modules, and thefedoratest withausearch -m AVCneeds them too.tamnd commentedon Nov 7, 2026
Item 3, part 1 of 5: #657 adds the AppArmor module and its securityfs tree. The module is on with
apparmor=1or whenlsm=names it. /sys/kernel/security/apparmor hasfeatures/,profiles,revision,.load,.replace,.removeandpolicy/. A load gives EPROTO for now. Next: the unpack of the binary policy and the profile tree. Item 3 stays open.tamnd commentedon Nov 8, 2026
Item 3, part 2 of 6: #662 unpacks the binary policy of
apparmor_parserand keeps the tree of profiles..load,.replaceand.removechange the tree, andprofilesandrevisionshow it. The audit records of the changes go to the kernel log, as on Linux. Next: the label of a task, the attach at exec, the learning profiles and /proc/PID/attr. Item 3 stays open.tamnd commentedon Nov 8, 2026
Item 3, part 3 of 6: #666 attaches the profiles at exec. The cred of a task holds its label. A program gets the profile that matches its path, with the conflict check of Linux. The exec rules give the next label, with the
ix,px,cxanduxfallbacks. In complain mode, an exec with no rule makes a learning profilePARENT//null-NAMEand anALLOWEDrecord in the kernel log./proc/PID/attr/currentshows the label and the mode. Next: the file hooks with the DFA match of the path. Item 3 stays open.tamnd commentedon Nov 9, 2026
Item 3, part 4 of 6: #672 checks the open files with the file rules of the profiles: an open, a read, a write, an
flockand anmmap. The name of a directory ends with/, and an open file keeps the label and the permissions that the rules checked. In complain mode, an operation that the rules do not allow goes on with anALLOWEDrecord in the kernel log, as on Linux. Next:change_profileandchange_hat. Item 3 stays open.tamnd commentedon Nov 9, 2026
Item 3, part 5 of 6: #677 lets a task change its label with
changehat,changeprofileandexecin /proc/self/attr and withlsm_set_self_attr. A hat keeps the label before it with a token, and a wrong token kills the task. In complain mode, a missing hat or profile gives a learning profile. The records in the kernel log are as on Linux. Next: the tests ofapparmor_parserandaa-statusand the regression tests. Item 3 stays open.tamnd commentedon Nov 11, 2026
Item 3, part 6 of 6: #693 adds the child policy namespaces and the stacks of AppArmor, and a fix of the exec hook for a script. With it,
apparmor_parserloads the 162 profiles of Ubuntu 26.04, andaa-statuslists them with the same modes as on Linux. tools/apparmor runs the AppArmor regression tests in complain mode under QEMU, on rukernel and on Linux 6.8.0-147-generic. The reference passes 5 of the 16 tests of the load and the attach (profiles, at_secure, complain, environ, longpath), with 198 checks. rukernel passes all these tests and checks, so it reaches the pass set of the reference. tools/apparmor/report.md has the results. Item 3 is done.11 remaining items
tamnd commentedon Nov 14, 2026
Item 4 is done. AppArmor works in enforce mode with the file, capability, signal, ptrace, network, user namespace, mount and Unix socket rules (#698, #710, #715, #716, #718, #723, #725, #727, #728, #731). A denial gives
EACCESand a record with the fields of Linux. The AppArmor regression tests reach the pass set of Linux 6.8.usernsandnet_inetfail on Linux 6.8 too. Theubuntuboot test boots Ubuntu 26.04 with AppArmor in enforce mode tomulti-user.target(#736).tamnd commentedon Nov 14, 2026
Item 7: #739 is merged. The
apparmorboot test now checks that a denial of AppArmor goes to auditd as anAUDIT_AVCrecord with the fields of Linux, and that the groupAUDIT_NLGRP_READLOGgets the same record, as journald reads it. A record that goes to auditd does not go to the kernel log. The test passes on x86_64 and arm64. The item stays open: its exit needsausearch -m AVCon thefedoraboot test of the SELinux items.selinux: the binary policy, selinuxfs and the modes of SELinux (#757)
selinux: the security server, the AVC and the transaction files (#787)
selinux: the SIDs of the tasks, the exec transitions and /proc/PID/at…
selinux: the labels of the inodes from fs_use and genfscon, and secur…
tamnd commentedon Nov 18, 2026
Item 5, part 5: #799 is merged. It adds the first permission checks of SELinux, as hooks.c of Linux:
selinux_inode_permissionfor a path walk,accessand an open,selinux_file_openwith the policy capabilityopen_perms,selinux_inode_getattrforstat, andselinux_inode_setattrforchmod,chown,utimensatand a truncate. The records of the log have thename,path,devandinofields of Linux. Theselinuxboot test passes on x86_64 and arm64 with 83 of 83 checks. The earlier parts are #757, #787, #790 and #795. The directory operations and the labels of new files come next.tamnd commentedon Nov 20, 2026
Item 5, part 6: #803 is merged. It adds the SELinux checks of the operations on the names of the directories, as
may_create,may_linkandmay_renameof hooks.c of Linux:add_name,remove_name,search,reparentandrmdiron the directory,create,link,unlinkandrenameon the file, andassociatewith the file system, for a create,mkdir,mknod,symlink,link,unlink,rmdirandrename. The label for the checks of a new file comes fromfscreateor from thetype_transitionrule for its name. Theselinuxboot test passes on x86_64 and arm64 with 95 of 95 checks. The earlier parts are #757, #787, #790, #795 and #799. The label of the new inode and a write ofsecurity.selinuxcome next.tamnd commentedon Nov 20, 2026
Item 5, part 7: #804 is merged. A new file now gets its SELinux label when the VFS makes it, from
fscreateor from thetype_transitionrule for its name, and a file system that keeps the labels gets the attributesecurity.selinux, asselinux_inode_init_securityof Linux. Asetxattrofsecurity.selinuxneeds the owner orCAP_FOWNER,relabelfrom,relabelto, thevalidatetransrules andassociate, andremovexattrof the label givesEACCES, asselinux_inode_setxattr,selinux_inode_post_setxattr,selinux_inode_setsecurityandselinux_inode_removexattr. The selinux boot test has 104 checks on x86_64 and arm64. Next:file_permission, ioctl, mmap,mprotect, locks andfcntl.tamnd commentedon Nov 20, 2026
Item 5, part 8: #805 is merged. An open file now keeps the SID of the task that made it, the label of the inode and the number of the policy load, as
struct file_security_structof Linux. A read or a write checks the permissions again if one of them changed, and a write to a file withO_APPENDneedsappend, asselinux_file_permission. A file of another SID needsuseof the classfd, a lock needslock, and anF_SETFLthat removesO_APPENDneedswrite, asfile_has_perm,selinux_file_lockandselinux_file_fcntl. The test policy has the new ruleallow kernel_t self : fd use, because the kernel opens the console with the SIDkerneland init runs with the SIDinit. The selinux boot test has 112 checks on x86_64 and arm64. Next: ioctl with the extended permissions, thenmmapandmprotect.tamnd commentedon Nov 20, 2026
Item 5, part 9: #812 is merged. An
ioctlnow has the SELinux checks of Linux, asselinux_file_ioctlandioctl_has_perm, with the extended permissions of theallowxperm,auditallowxpermanddontauditxpermrules, asavc_has_extended_permsandsecurity_compute_xperms_decision. A command needsioctland, if the policy has rules for its driver, the rule for its function. The AVC keeps the decisions of each driver, and the records haveioctlcmd.FIONREAD,FIBMAP,FIGETBSZand the commands that read the flags needgetattr, the commands that change them needsetattr,FIONBIOandFIOASYNCneed onlyuseof the descriptor, andKDSKBENTandKDSKBSENTneedsys_tty_config, ascred_has_capability. The selinux boot test has 116 checks on x86_64 and arm64. Next:mmap_file(part 10), thenfile_mprotectin four small parts after the reclaim change of #752 merges.tamnd commentedon Nov 21, 2026
Item 5, part 10: #821 is merged. A map of a file or of anonymous memory now has the SELinux checks of Linux, as
selinux_mmap_fileandfile_map_prot_check. A map of a file needsmap,read,writeif it is shared and can write, andexecuteif it can run code. A map that can run code needsexecmemof the process if it is anonymous memory, a file without an inode, or a private map that can also write. The selinux boot test has 122 checks, and they pass on x86_64 and arm64. The 52 unit tests pass. Next:file_mprotect, after the PR of #752 item 3 merges, and the checks of the processes (signals, ptrace, the scheduler and the capabilities), which do not need #752.tamnd commentedon Nov 21, 2026
Item 5, part 11: #822 is merged. The operations on other tasks now have the SELinux checks of Linux, as
selinux_task_kill, the other task hooks,selinux_capget,selinux_capset,selinux_ptrace_access_checkandselinux_ptrace_traceme. A signal needssigkill,sigstop,sigchld,signullfor the signal 0, orsignal.getpgid,getsidandsetpgidof a PID needgetpgid,getsessionandsetpgid. A change of the nice value, of the I/O priority or of the scheduler needssetsched, and a read of them needsgetsched.prlimiton another process needsgetrlimitorsetrlimit,capgetneedsgetcap,capsetneedssetcap, andPTRACE_ATTACHandPTRACE_TRACEMEneedptrace. Ascheck_prlimit_permissionof Linux,prlimiton the caller itself does not call the hook. The selinux boot test has 134 checks, and they pass on x86_64 and arm64. The 53 unit tests pass. Next: the checks of the mounts (mounton,remount,unmount), which do not need #752, andfile_mprotectafter the PR of #752 item 3 merges.tamnd commentedon Nov 21, 2026
Item 5, part 12: #824 is merged. The mounts now have the SELinux checks of Linux, as
selinux_mount,selinux_move_mountandselinux_umount. A new mount and a move of a mount needmountonon the place of the mount, a remount needsremountof the file system, and an unmount needsunmountof the file system. The selinux boot test has 140 checks, and they pass on x86_64 and arm64. The 55 unit tests pass. Next:file_mprotectafter the PR of #752 item 3 merges. Other parts that do not need #752:selinux_capable, the checks of the sockets and the checks of System V IPC.tamnd commentedon Nov 23, 2026
Item 5, part 13: #828 is merged. The capable hook gets the user namespace, and SELinux checks each capability through the AVC in the classes capability and capability2, or cap_userns and cap2_userns in a user namespace that is not the first one, as cred_has_capability of Linux. The checks of CAP_MAC_ADMIN for the labels use the same function. Tests: 56 unit tests, and 145 of 145 boot tests on x86_64 and arm64. Next: the checks of the System V IPC objects.