Skip to content

Empty / deny-all ruleset #48

@lanodan

Description

@lanodan

Maybe I missed something and there's a better way, but it seems like you can't create an empty ruleset or restrict to an empty one to deny all (further) access.

Doesn't works with an fd of 0 and not aware of a magic value for fd which could instead work:

landlock_restrict_self(0, 0)            = -1 EBADFD (File descriptor in bad state)

And creating an empty ruleset:

landlock_create_ruleset({handled_access_fs=0, handled_access_net=0, scoped=0}, 24, 0) = -1 ENOMSG (No message of desired type)
landlock_create_ruleset(NULL, 0, 0)     = -1 EFAULT (Bad address)

(strace output, tested on Linux 6.12.31)

By the way at least 2 cases where an empty ruleset can make sense:

  • Programs which only processes base/inherited accesses (environment variables, arguments, stdin/stdout/stderr, passed fds, …). Filters inside of pipelines or as child process being probably the most sensitive of those.
  • Programs which are done configuring & setting up and shouldn't access further files (rather typical of long-lived user & system programs like dæmons)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions