Skip to content

v0.5.38

Choose a tag to compare

@tamnd tamnd released this 21 Nov 12:28
· 9 commits to main since this release
v0.5.38
7c4261b

Added

  • SELinux checks the ioctl commands with the extended permissions, as selinux_file_ioctl, ioctl_has_perm and avc_has_extended_perms of Linux. A command needs ioctl and, if the policy has allowxperm rules for the source, the target and the class, a rule for the driver (the high byte of the command) and for the function (its low byte). The access vector cache keeps the drivers of the rules and the decisions of each driver, and dontauditxperm and auditallowxperm rules control the records, which have the field ioctlcmd. FIONREAD, FIBMAP, FIGETBSZ and the commands that read the flags or the version of an inode need getattr, the commands that change them need setattr, FIONBIO and FIOASYNC need only use of the descriptor, and KDSKBENT and KDSKBSENT need the capability sys_tty_config, as cred_has_capability of Linux. FIOCLEX and FIONCLEX need no permission if the policy has the capability ioctl_skip_cloexec (#540).
  • SELinux checks the open files, as selinux_file_permission, selinux_file_lock and selinux_file_fcntl of hooks.c of Linux. Each file keeps the SID of the task that made it, and an open keeps the label of the inode and the number of the policy load. A read or a write checks the permissions again only if another SID uses the file, if the label of the file changed, or after a policy load, and a write to a file with O_APPEND needs append. A file of another SID needs use of the class fd. flock and the lock commands of fcntl need lock, an F_SETFL that removes O_APPEND needs write, and the commands of the flags, the owner and the signal need use. The test policy lets the domains use the character devices, so the console of the boot test works in enforcing mode (#540).
  • SELinux gives the new files their labels and checks the changes of security.selinux, as selinux_inode_init_security, selinux_inode_setxattr, selinux_inode_post_setxattr, selinux_inode_setsecurity and selinux_inode_removexattr of hooks.c of Linux. A new file of open, mkdir, mknod, symlink or O_TMPFILE gets the label of fscreate or of the type_transition rule when the VFS makes it, and a file system that keeps the labels gets the attribute security.selinux. A setxattr of security.selinux needs the owner of the file or CAP_FOWNER, relabelfrom, relabelto, the validatetrans rules of the class and associate with the file system, and a context that the policy does not know needs CAP_MAC_ADMIN. The label cannot be removed after the first policy load, and a change of another attribute needs setattr. The new hooks inode_init_security, inode_setxattr, inode_post_setxattr, inode_setsecurity and inode_removexattr come at the places of Linux (#540).
  • SELinux checks the operations on the names of the directories, as may_create, may_link and may_rename of hooks.c of Linux: a new file of open, mkdir, mknod or symlink needs add_name and search on the directory, create on the label of the new file, from the type_transition rule for its name or from fscreate, and associate with the file system. link, unlink and rmdir need add_name or remove_name and link, unlink or rmdir, and rename needs remove_name, rename, reparent for a directory that moves, and add_name. The new hooks inode_create, inode_mkdir, inode_mknod, inode_symlink, inode_link, inode_unlink, inode_rmdir and inode_rename come after the permission checks of the directories, as in Linux.
  • The BPF verifier tracks the precision of the scalars, as mark_chain_precision of Linux. A scalar is precise only when the safety of the program needs its exact value, for example an offset of a pointer or a branch that the verifier knows. The pruning compares only the precise scalars, so a loop with a counter that only counts does not keep a new state for each value. A helper call reads only the registers of its arguments for the liveness, and a constant offset in a frozen map with BPF_F_RDONLY_PROG reads as a constant, as bpf_map_direct_read of Linux. The verifier now processes 25505 instructions for each of sd_bind4 and sd_bind6 of systemd 257, and 16 for sd_restrictif, the same as Linux 6.8. Before, it processed 39829 for sd_bind4 and 24 for sd_restrictif. (#762)
  • tools/systemd/networkd.md and tools/systemd/nettest.py: how to run systemd-networkd-tests.py and TEST-75-RESOLVED of systemd 257.13 on rukernel and on Linux under QEMU, the results of each test class on x86_64, the kernel fixes, and the tests that do not pass yet with their causes (#538).
  • A write of 2 or 3 to /proc/sys/vm/drop_caches removes the evictable fanotify marks (FAN_MARK_EVICTABLE) of the inodes that no one else uses, as the eviction of the unused inodes and fsnotify_inode_delete in Linux. A value outside 1 to 4 gives EINVAL, as in Linux. LTP fanotify10 and fanotify23 use this (#539).
  • An IPv4 route can go through an IPv6 gateway, as Linux 5.2 and later. RTM_NEWROUTE and RTM_DELROUTE take RTA_VIA with the checks of fib_gw_from_via, and a route or a nexthop with an IPv6 gateway is checked as fib_check_nh_v6_gw. The dump and RTM_GETROUTE give RTA_VIA with the family AF_INET6, so ip route shows via inet6. A packet on this route goes to the link address of the gateway from the neighbour discovery, with the type of IPv4. Before, the kernel did not use RTA_VIA, and a route through a nexthop with an IPv6 gateway gave EOPNOTSUPP. An IPv6 route with RTA_VIA gives EINVAL, as in Linux (#538).
  • cgroup2 has file handles, as the export ops of kernfs in Linux: name_to_handle_at gives the type FILEID_KERNFS and the inode number in 8 bytes, which for a cgroup is the ID that PIDFD_GET_INFO and bpf give. Before, it gave EOPNOTSUPP, so systemd read the cgroup ID as 0 and NFTSet=cgroup: added no element (TEST-75 testcase_11_nft, #538). open_by_handle_at finds the cgroup or its file, and gives ESTALE for a cgroup that was removed or that is not below the root of the mount. The new file has its path in the mount of mount_fd, as reconnect_path of Linux, so /proc/self/fd shows /sys/fs/cgroup/....
  • fanotify has the pre-content event FAN_PRE_ACCESS on ext3, ext4 and XFS, as SB_I_ALLOW_HSM of Linux 7.x. The ext2 driver does not allow it, as in Linux, so a mark on ext2 gives EOPNOTSUPP. An open decides if the file gets the events, as FMODE_FSNOTIFY_HSM. A read, a write, an mmap, a fallocate and a truncate of such a file give the event before the access, with a FAN_EVENT_INFO_TYPE_RANGE record of the pages of the access, and an answer can deny the access with an error. A program that a group watches for the events can run while a file opens it for a write. LTP fanotify24 now passes on ext3 and ext4, and gives TCONF on ext2 as in Linux (#539).
  • A lookup in /proc/PID and /proc/PID/task/TID makes only the inode of the name, as proc_pident_lookup of Linux. Before, each lookup made all of the about 50 entries of the directory, and a walk of /proc/self/fd/N for each fanotify event made LTP fanotify05 slow (#539).
  • ext2, ext3 and ext4 find a free inode in the inode bitmap 64 bits at a time, as find_next_zero_bit of Linux, in place of one bit at a time from the start of the group. The creates of LTP fanotify05 are faster (#539).

Fixed

  • getsockopt of IP_PKTOPTIONS and IPV6_2292PKTOPTIONS on a TCP socket gives the control messages of IP_PKTINFO, IP_TTL, IPV6_PKTINFO, IPV6_HOPLIMIT and IPV6_TCLASS with the interface and the TTL of the SYN, as Linux. Before, it gave ENOPROTOOPT, and systemd-resolved closed each TCP connection to its stub resolver before the reply, so dig +tcp and dig AXFR to 127.0.0.53 got "connection reset" and TEST-75-RESOLVED stopped (#538).
  • RTM_SETLINK takes IFLA_INET6_ADDR_GEN_MODE in IFLA_AF_SPEC, and each link has the attributes of AF_INET6 in IFLA_AF_SPEC, as inet6_validate_link_af, inet6_set_link_af and inet6_fill_link_af of Linux. A family in IFLA_AF_SPEC that the kernel does not have gives EAFNOSUPPORT, and a family without changes gives EOPNOTSUPP, before any change. A device with addr_gen_mode 1, IN6_ADDR_GEN_MODE_NONE, gets no link local address when it goes up, and a write of another mode to net.ipv6.conf.DEV.addr_gen_mode makes the address when the device is up. The mode 2 needs stable_secret, so a device does not take it. Before, systemd-networkd did not see the mode of a link and the link had no link local address after a change of its .network file (#538).
  • An IPv6 gateway of a new route or nexthop is on the link while each address of the interface is tentative, as ip6_route_check_nh of Linux. Before, the check looked for a source address too, so ip -6 nexthop add id 2 via 2001:1234:5:8f63::2 dev veth99 right after the address 2001:1234:5:8f63::1/120 gave EHOSTUNREACH, and systemd-networkd failed the link in test_nexthop (#538).
  • nf_tables: an insert in a set with timeouts no longer goes through the whole set. A batch removes the elements that expired once in each set, at its first insert there, as the garbage collection of Linux does it apart from the inserts. Before, each element of a batch went through all the elements of the set twice, so a batch of 400 elements in a set of 10000 looked at 8159600 elements, and now at 10000. As set->nelems of Linux, the size of a set counts an element that expired until it is removed. A get of an element (nft get element) no longer copies the set (#542).