public inbox for linux-security-module@vger.kernel.org
 help / color / mirror / Atom feed
From: Justin Suess <utilityemal77@gmail.com>
To: linux-security-module@vger.kernel.org,
	"Mickaël Salaün" <mic@digikod.net>
Cc: "Günther Noack" <gnoack@google.com>,
	"Tingmao Wang" <m@maowtm.org>,
	"Justin Suess" <utilityemal77@gmail.com>
Subject: [PATCH v2 0/2] landlock: Simplify path walk logic
Date: Mon,  2 Mar 2026 23:05:38 -0500	[thread overview]
Message-ID: <20260303040540.3124770-1-utilityemal77@gmail.com> (raw)

Hello,

This is v2 of a 2-patch Landlock cleanup series for security/landlock/fs.c.

These patches simplify path handling and path-based access checks. The cleanup
was initially part of my LANDLOCK_ADD_RULE_NO_INHERIT work, but it is more
appropriate as a separate preparatory series.

v1: https://lore.kernel.org/linux-security-module/20260218201857.1194667-1-utilityemal77@gmail.com/

Changes since v1
-----

- Split and clarified the series as:
  1) "landlock: Add path walk helper"
  2) "landlock: Refactor path access checks"
- Introduced landlock_walk_path_up() and enum landlock_walk_result to
  centralize upward path traversal state.
- Refactored is_access_to_paths_allowed() and callers around a
  struct landlock_check state object.
- Inlined collect_domain_accesses() into current_check_refer_path() and
  reused current_check_access_path() for same-directory refer checks.

Motivation
-----

Current path-walk logic is tightly coupled to specific call sites and is hard
to read and maintain. Centralizing traversal and per-check state should make
future Landlock path-based features easier to implement and review, including
follow-up work related to no-inherit semantics.

Patch overview
-----

Patch 1 introduces landlock_walk_path_up(), which walks a struct path
toward the VFS root and reports whether the current position is an internal
mount point, the real root, or neither.

Patch 2 applies the helper to access-check paths, introduces a struct landlock_check
to aggregate reused local variables used to check accesses, and removes collect_domain_accesses()
as a standalone helper.

Patch 1 can be applied independently. Patch 2 contains some more aggressive trimming
and refactoring of logic enabled by the first patch.

Thank you for your time.

Kind regards,
Justin Suess

Justin Suess (2):
  landlock: Add path walk helper
  landlock: Refactor path access checks

 security/landlock/fs.c | 507 ++++++++++++++++++-----------------------
 1 file changed, 225 insertions(+), 282 deletions(-)


base-commit: 8ff74a72b8af3672beca7f6b6b72557a9db94382
-- 
2.51.0


             reply	other threads:[~2026-03-03  4:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03  4:05 Justin Suess [this message]
2026-03-03  4:05 ` [PATCH v2 1/2] landlock: Add path walk helper Justin Suess
2026-03-03  4:05 ` [PATCH v2 2/2] landlock: Refactor path access checks Justin Suess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260303040540.3124770-1-utilityemal77@gmail.com \
    --to=utilityemal77@gmail.com \
    --cc=gnoack@google.com \
    --cc=linux-security-module@vger.kernel.org \
    --cc=m@maowtm.org \
    --cc=mic@digikod.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox