Skip to content

allowing /proc/self without allowing all of /proc (like the default base profile does) can still block /proc/self in child processes #24

Description

@symphorien

The default base config allows reading /proc/self:
https://github.com/landlock-lsm/island/blob/main/assets/landlock/island-default-base.toml#L46

however this is not fully effective: (illustrated with the zsh integration)

$ LANG=C bash -c "head -n1 /proc/self/status; head -n1 /proc/self/status"
head: cannot open '/proc/self/status' for reading: Permission denied
Name:	head

my understanding is that:

  • the bash process, with PID X, has landlock ruleset allowing /proc/self as a symlink to /proc/X
  • first head command is executed with fork(), so has a different pid, so /proc/self points to a directory /proc/Y which is not allowed
  • second head command is executed with exec without fork, so proceeds to read /proc/X/status successfully

this is particularly annoying to debug.

Note that this is reproducible with landrun because it looks like a fundamental issue with landlock:

landrun --rw /home --rox /nix --rw /tmp --ro /etc/ --ro /proc/self --ro /run/current-system bash -c "/run/current-system/sw/bin/head /proc/self/status; /run/current-system/sw/bin/head /proc/self/status;"
head: cannot open '/proc/self/status' for reading: Permission denied
Name:	/run/current-sy
Umask:	0022
State:	R (running)
Tgid:	395443
Ngid:	0
Pid:	395443
PPid:	391428
TracerPid:	0
Uid:	1000	1000	1000	1000
Gid:	100	100	100	100

Maybe if island wants to hide other processes a pid namespace is more suitable? Or the whole of /proc should be allowed by default?

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