Skip to content

R5 uevents, the keyring, fanotify and inotify #539

Open

Description

@tamnd

Part of #14.

inotify is complete: LTP inotify* 14 pass. fanotify has the notification and content classes: 10 pass, fanotify05 fails on a busy host by its time limit, and 14 tests do not apply (FAN_REPORT_FID, FAN_REPORT_DIR_FID, FAN_REPORT_PIDFD, FAN_REPORT_TID, FAN_PRE_ACCESS and /proc/sys/vm/vfs_cache_pressure). The keyring has the user, logon and keyring types (core/rk-proc/src/keys): keyctl* 21 pass, request_key* 6 pass, keyctl05 fails because it runs modprobe, and 8 keyctl tests do not apply because of missing key types. There is no upcall to /sbin/request-key. There are no uevents: the uevent files of /sys can only be read, and there is no NETLINK_KOBJECT_UEVENT socket.

Scope

Done when

The LTP tests of uevents, the keyring, fanotify and inotify reach the pass set of the reference. This is the exit of the fourth item of #14.

Test each task on x86_64 and on arm64. Give the result of both in the PR body.

Linux reference: lib/kobject_uevent.c, drivers/base/core.c, fs/notify/fanotify/fanotify_user.c, fs/notify/fanotify/fanotify.c, security/keys/request_key.c, crypto/asymmetric_keys/x509_cert_parser.c, security/keys/dh.c.

Activity

  1. added
    kind/featureNew behavior or a new part.
    area/vfsThe VFS, the dentry cache, procfs and sysfs.
    area/driversDevice drivers and virtio.
    area/securityLSMs, seccomp, Landlock, capabilities and mitigations.
    on Nov 2, 2026
  2. tamnd commented on Nov 3, 2026

    @tamnd
    OwnerAuthor

    #562 is merged. It adds the device events on NETLINK_KOBJECT_UEVENT sockets: add, remove and change of character, block and loop devices go to all namespaces, and add, remove and move of network devices and their queues go only to the namespace of the device. /sys/kernel/uevent_seqnum gives the last number. LTP uevent01 and uevent02 pass on x86_64. uevent03 gives TCONF, because it needs uinput and the input devices. Thus the first item stays open. The uevent checks of the init boot test pass on x86_64 and arm64.

  3. tamnd commented on Nov 3, 2026

    @tamnd
    OwnerAuthor

    #563 is merged. It adds the synthetic device events. A write of ACTION [UUID [KEY=VALUE ...]] to the file uevent of a device in /sys sends the event of that device, with SYNTH_UUID (0 without a UUID) and a SYNTH_ARG_KEY variable for each pair, as kobject_synth_uevent of Linux. An unknown action or a bad argument gives EINVAL. A device that does not exist gives ENODEV. The event of a network device goes only to its namespace.

    Tests (server2, load 21 to 25): the unit tests of rk-vfs, rk-net and rk-fs-sys pass. RK_CMDLINE="-- only uevent" cargo xtask boot-test init passes on x86_64 (also with the bzImage and UEFI) and on arm64. The gate is ok.

    The item stays open. Its exit needs the udevd boot test with udevadm trigger and udevadm settle on the image of the systemd boot test, and the /dev/disk/by-path links need the PCI tree of #543. Only the devices under /sys/devices/virtual have a writable uevent file now.

  4. tamnd commented on Nov 4, 2026

    @tamnd
    OwnerAuthor

    #571 is merged. It adds the input devices and /dev/uinput. UI_DEV_CREATE makes inputN with its eventN handler (and mouseN for a mouse) and sends their add events with the variables of Linux (PRODUCT, NAME, PROP, EV, KEY, REL, MODALIAS, and MAJOR, MINOR and DEVNAME for the handlers). UI_DEV_DESTROY sends the remove events. It also adds /sys/devices/virtual/input, /sys/class/input and /proc/bus/input/devices. The handlers do not give input events yet.

    Tests on server2 at load 15 to 56: LTP uevent01, uevent02 and uevent03 pass on x86_64 (uevent03 gave TCONF before). The only uevent boot test passes on x86_64 (bzImage and UEFI) and arm64. The gate of #571 is ok.

    With #562 and #571, the exit of the uevent item is met, so I ticked it.

  5. tamnd commented on Nov 4, 2026

    @tamnd
    OwnerAuthor

    #573 is merged. It adds the dns_resolver key type (binary server list and text form, no update, a list with no good lookup expires after one second). A new key of a type with no update now gets no write permission, as Linux.

    The cause of the modprobe failure of keyctl05: the modprobe of BusyBox gives 0 only for a module in /proc/modules or modules.builtin. The LTP init script listed only veth and dummy in modules.builtin, and rukernel had no dns_resolver type. tools/ltp/run.py now lists dns_resolver.

    Tests on server2 at load 15 to 29: keyctl05 passes on x86_64 (TBROK before), and request_key01 to request_key06 pass. The new init checks pass on x86_64 (bzImage and UEFI) and arm64. There is no arm64 LTP build on the servers. The gate of #573 is ok.

    The keys item stays open. Not done yet: the upcall to /sbin/request-key with the authorization key (the kernel has no way to start a user program yet), KEYCTL_INSTANTIATE, KEYCTL_REJECT and KEYCTL_ASSUME_AUTHORITY (they need the authorization key), the big_key type, the dnserror error of a dns_resolver key, and the keyctl part of the systemd boot test.

  6. tamnd commented on Nov 4, 2026

    @tamnd
    OwnerAuthor

    #575 adds socket filters (SO_ATTACH_FILTER, SO_DETACH_FILTER, SO_LOCK_FILTER) to netlink sockets, as sk_filter in netlink_unicast and netlink_broadcast of Linux. The udev monitor of systemd (sd-device and libudev) needs this for its NETLINK_KOBJECT_UEVENT socket. The kernel's own replies do not go through the filter, as in Linux.

    Tests on server2: cargo test -p rk-net netlink 17 pass. The new only uevent init check passes on x86_64 (bzImage and UEFI) and arm64: a datagram with the libudev header gets through the filter, a plain kernel-style event is dropped, and after SO_LOCK_FILTER a detach gives EPERM. The systemd boot test stops earlier, at the generators, with or without this change (see #536), so it does not show the udev monitor yet.

    Still open in this issue: the synthetic uevent item needs the udevd boot test and the PCI tree of #543. The keys item needs the /sbin/request-key upcall, KEYCTL_INSTANTIATE, KEYCTL_REJECT, KEYCTL_ASSUME_AUTHORITY, big_key, the dnserror option of dns_resolver, and the keyctl part of the systemd boot test.

  7. tamnd commented on Nov 4, 2026

    @tamnd
    OwnerAuthor

    Keys, step 1, is in #579. It adds key construction with the .request_key_auth key, plus KEYCTL_ASSUME_AUTHORITY, KEYCTL_INSTANTIATE, KEYCTL_INSTANTIATE_IOV, KEYCTL_NEGATE and KEYCTL_REJECT. The upcall that runs /sbin/request-key comes next.

  8. tamnd commented on Nov 4, 2026

    @tamnd
    OwnerAuthor

    Keys, step 2, is in #586. It adds the user mode helper (kernel/umh.c), and with it request_key now runs /sbin/request-key for a construction. Next comes big_key and storing the dnserror option.

  9. tamnd commented on Nov 4, 2026

    @tamnd
    OwnerAuthor

    Keys, step 3, is in #587: the big_key type, and dns_resolver keys that keep the error of the dnserror option. That ends the three keys steps (#579, #586 and this PR).

  10. tamnd commented on Nov 5, 2026

    @tamnd
    OwnerAuthor

    #611 adds SO_PASSCRED and SCM_CREDENTIALS to netlink sockets. The device monitor of systemd sets SO_PASSCRED on its NETLINK_KOBJECT_UEVENT socket and stops on an error. Before, the call gave ENOPROTOOPT, so systemd-logind stopped at the start, about 50 times in each systemd boot test. A uevent of the kernel now comes with PID, UID and GID 0, as on Linux.

    Results: cargo test -p rk-net netlink 19 passed. The uevent init checks pass on x86_64 (load average 14.63, 19.88, 25.37) and arm64 (load average 21.31, 20.82, 23.68), with a new check of SO_PASSCRED. In the systemd boot test on server1 (load average about 1), logind starts and no systemd-logind.service failure is logged.

    No box changes. This fix is not one of the items of this issue.

  11. tamnd commented on Nov 6, 2026

    @tamnd
    OwnerAuthor

    fanotify with file handles: #626 merged.

    • FAN_REPORT_FID, FAN_REPORT_DIR_FID, FAN_REPORT_NAME and FAN_REPORT_TARGET_FID work, with the handles of name_to_handle_at, the dirent events, FAN_RENAME and the self events.
    • An unprivileged group gives the pid 0 for the events of other processes.
    • LTP x86_64: fanotify14, fanotify15, fanotify16, fanotify18 and fanotify19 pass. fanotify13 passes its first variant on ext2 and tmpfs.

    What remains for this item:

    • fanotify13 overlayfs variants: the overlayfs of rukernel must send the open and close events of the real file to the base file system.
    • fanotify17: the limits of the groups and marks of a user (/proc/sys/fs/fanotify/max_user_groups and max_user_marks, EMFILE and ENOSPC).
    • xfs has no file_handle, so a mount or file system mark of a FID group on xfs gives EOPNOTSUPP.
  12. tamnd commented on Nov 6, 2026

    @tamnd
    OwnerAuthor

    fanotify13 overlayfs variants: #628 merged.

    • The open, access, modify and close of an overlayfs file are also events of the real file in the layer below. A mark on the inode or on the file system of a layer gets them.
    • The unlink of a lower file through overlayfs gives the node a link count of 0, so the delete self events come.
    • LTP x86_64: fanotify13 now passes. fanotify01 to 04, 14 to 16, inotify07 and inotify08 still pass.

    What remains for item 1: fanotify17 (the limits of the groups and marks of a user), and xfs has no file_handle.

  13. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    fanotify group and mark limits: #635 merged.

    • A group counts for its user in the user namespaces, and over the limit fanotify_init gives EMFILE. A mark counts for the same user, and over the limit it gives ENOSPC.
    • /proc/sys/fs/fanotify/max_user_groups, max_user_marks and max_queued_events are new.
    • LTP x86_64: fanotify17 now passes. fanotify13 to fanotify19 all pass now.

    What remains for item 1: xfs has no file_handle, so a mount or file system mark of a FID group on xfs gives EOPNOTSUPP. The image has no mkfs.xfs, so LTP did not test xfs. Item 2 (FAN_REPORT_PIDFD, FAN_REPORT_TID, FAN_REPORT_MNT, fanotify20 and fanotify21) is not started.

  14. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    XFS file handles: #638 merged.

    • name_to_handle_at on XFS gives the handle FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG with the inode number and the generation, and open_by_handle_at finds the inode again, as fs/xfs/xfs_export.c of Linux.
    • A fanotify group that reports file handles can now mark a mount or a file system of XFS.
    • cargo test -p rk-fs-xfs passes. LTP did not test XFS, because the image has no mkfs.xfs.

    Item 1 is now complete: ext4, XFS and tmpfs give file handles, and LTP fanotify13 to fanotify19 pass on x86_64. What remains: item 2 (FAN_REPORT_PIDFD, FAN_REPORT_TID with a pidfd, FAN_REPORT_MNT, fanotify20 and fanotify21).

  15. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    fanotify FAN_REPORT_PIDFD: #643 merged.

    • Each event has a pidfd info record. With FAN_REPORT_TID the pidfd refers to the thread. FAN_NOPIDFD, FAN_EPIDFD and the FAN_REPORT_FD_ERROR errors are as in Linux.
    • The pid of an event is now the ID in the PID namespace of the reader.
    • LTP x86_64: fanotify21 passes (60 TPASS, 0 TFAIL). fanotify20 gives TCONF, as on Linux 7.2 and later, because FAN_REPORT_PIDFD | FAN_REPORT_TID is now allowed.

    What remains for item 2: FAN_REPORT_MNT (the mount events FAN_MNT_ATTACH and FAN_MNT_DETACH and the marks on a mount namespace). fanotify20 cannot pass on a kernel of 7.2 or later, so its exit is TCONF.

  16. tamnd commented on Nov 7, 2026

    @tamnd
    OwnerAuthor

    Synthetic uevents: #646 merged.

    • The disks and the network interfaces of the virtio devices are now in the directories of their virtio devices in sysfs, as on Linux, for example /sys/devices/pci0000:00/0000:00:02.0/virtio1/block/vda. A write of add, change or remove to their uevent files sends the event with the optional UUID and variables.
    • The new udevd boot test boots the tree of the systemd test, runs udevadm trigger --action=add and udevadm settle, and checks /dev/disk/by-path. On x86_64 (server1, load 1.0) it passes: settle ends, ID_PATH is pci-0000:00:02.0, and /dev/disk/by-path has pci-0000:00:02.0 and virtio-pci-0000:00:02.0 to vda. The systemd test also passes with the new tree.
    • By hand on arm64 with the same tree (server2, load 3 to 9), udevadm settle ends and /dev/disk/by-path has platform-a003e00.virtio_mmio to vda. Linux 6.8 on x86_64 and the Linux arm64 build give the same links with the same tree.
    • The item is done. The udevd test runs only on x86_64 in xtask. systemd-resolved is not in the tree yet, because it stops with ENOPROTOOPT on rukernel. That is for the networkd test of R5 netlink: rules, nexthops, generic netlink and ethtool for networkd, resolved and udevd #538.
  17. tamnd commented on Nov 12, 2026

    @tamnd
    OwnerAuthor

    #706 is merged. It adds FAN_REPORT_MNT, so the item "fanotify with pidfds and mount events" is done (FAN_REPORT_PIDFD and FAN_REPORT_TID came in #643).

    • A group with FAN_REPORT_MNT marks a mount namespace with FAN_MARK_MNTNS. It gets FAN_MNT_ATTACH and FAN_MNT_DETACH on mount, move, unmount and pivot_root, with a FAN_EVENT_INFO_TYPE_MNT record of 16 bytes that has the unique mount ID. The errors and the record layout are the same as in Linux 7.3.
    • LTP 20260930 has no test for FAN_REPORT_MNT. The init boot test (only fanotify) has 17 checks for it: pass on x86_64 and arm64, load average 18.9 to 22.3.
    • LTP on server2: fanotify18, fanotify19 and fanotify21 pass on x86_64 and arm64. fanotify20 gives TCONF ("FAN_REPORT_PIDFD | FAN_REPORT_TID is supported since v7.2") on both, the same as the Linux 7.3 reference. On x86_64, fanotify21 had a timeout at the default limit of 240 s at load 18.5 to 21, and passed in 234 s with a limit of 1200 s at load 15 to 17.5.

    The full gate did not run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/driversDevice drivers and virtio.area/securityLSMs, seccomp, Landlock, capabilities and mitigations.area/vfsThe VFS, the dentry cache, procfs and sysfs.kind/featureNew behavior or a new part.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions