landlock: Align partial refer access checks with final ones
authorMickaël Salaün <mic@digikod.net>
Wed, 8 Jan 2025 15:43:19 +0000 (16:43 +0100)
committerMickaël Salaün <mic@digikod.net>
Fri, 17 Jan 2025 18:05:35 +0000 (19:05 +0100)
commit058518c2092081f224edb37cbc236bed5c28852d
tree4a0a4ae7f51bc8808cf6f48deac2b3ffb41bf850
parentd6c7cf84a24fff332ff65ffe236302216474b834
landlock: Align partial refer access checks with final ones

Fix a logical issue that could have been visible if the source or the
destination of a rename/link action was allowed for either the source or
the destination but not both.  However, this logical bug is unreachable
because either:
- the rename/link action is allowed by the access rights tied to the
  same mount point (without relying on access rights in a parent mount
  point) and the access request is allowed (i.e. allow_parent1 and
  allow_parent2 are true in current_check_refer_path),
- or a common rule in a parent mount point updates the access check for
  the source and the destination (cf. is_access_to_paths_allowed).

See the following layout1.refer_part_mount_tree_is_allowed test that
work with and without this fix.

This fix does not impact current code but it is required for the audit
support.

Cc: Günther Noack <gnoack@google.com>
Link: https://lore.kernel.org/r/20250108154338.1129069-12-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
security/landlock/fs.c