public inbox for linux-security-module@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] landlock: Refactor layer masks
@ 2025-12-30 10:39 Günther Noack
  2025-12-30 10:39 ` [RFC PATCH 1/2] landlock: access_mask_subset() helper Günther Noack
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Günther Noack @ 2025-12-30 10:39 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: linux-security-module, Tingmao Wang, Justin Suess,
	Samasth Norway Ananda, Matthieu Buffet, Mikhail Ivanov,
	konstantin.meskhidze, Günther Noack

Hello!

This patch set "transposes" the layer masks matrix, which was
previously modeled as a access-max-sized array of layer masks, and
changes it to be a layer-max-sized array of access masks instead.
(It is a pure refactoring, there are no user-visible changes.)

This unlocks a few code simplifications and in multiple places it
removes the need for loops and branches that deal with individual
bits.  Instead, the changed data structure now lends itself for more
bitwise operations.  The underlying hypothesis for me was that by
using more bitwise operations and fewer branches, we would get an
overall speedup even when the data structure size increases slightly
in some cases.

Tentative results with and without this patch set show that the
hypothesis likely holds true.  The benchmark I used exercises a "worst
case" scenario that attempts to be bottlenecked on the affected code:
constructs a large number of nested directories, with one "path
beneath" rule each and then tries to open the innermost directory many
times.  The benchmark is intentionally unrealistic to amplify the
amount of time used for the path walk logic and forces Landlock to
walk the full path (eventually failing the open syscall).  (I'll send
the benchmark program in a reply to this mail for full transparency.)

Measured with the benchmark program, the patch set results in a
speedup of -8.3%.  The benchmark results are only tentative and have
been produced in Qemu:

With the patch, the benchmark runs in 5932 clocks (measured with
times(3)):

*** Benchmark ***
10000 dirs, 100000 iterations, with landlock
*** Benchmark concluded ***
System: 5932 clocks
User  : 1 clocks
Clocks per second: 1000000

Without the patch, we get 6472 clocks, which is 9.1% more.

*** Benchmark ***
10000 dirs, 100000 iterations, with landlock
*** Benchmark concluded ***
System: 6472 clocks
User  : 1 clocks
Clocks per second: 1000000

The base revision used for benchmarking was commit 7a51784da76d
("tools/sched_ext: update scx_show_state.py for scx_aborting change")

In real-life scenarios, the speed improvement from this patch set will
be less pronounced than in the artificial benchmark, as people do not
usually stack directories that deeply and attach so many rules to
them, and the EACCES error should also be the exception rather than
the norm.

I am looking forward to your feedback.

P.S.: I am open to suggestions on what the "layer masks" variables
should be called, because the name "layer masks" might be less
appropriate after this change.  I have not fixed up the name
everywhere because fixing up the code took priority for now.

Günther Noack (2):
  landlock: access_mask_subset() helper
  landlock: transpose the layer masks data structure

 security/landlock/access.h  |  10 +-
 security/landlock/audit.c   | 155 ++++++----------
 security/landlock/audit.h   |   3 +-
 security/landlock/domain.c  | 120 +++---------
 security/landlock/domain.h  |   6 +-
 security/landlock/fs.c      | 361 +++++++++++++++++-------------------
 security/landlock/net.c     |  10 +-
 security/landlock/ruleset.c |  78 ++------
 security/landlock/ruleset.h |  18 +-
 9 files changed, 300 insertions(+), 461 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-01-28 21:49 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-30 10:39 [RFC PATCH 0/2] landlock: Refactor layer masks Günther Noack
2025-12-30 10:39 ` [RFC PATCH 1/2] landlock: access_mask_subset() helper Günther Noack
2026-01-09 16:06   ` Mickaël Salaün
2026-01-11 20:01     ` Günther Noack
2025-12-30 10:39 ` [RFC PATCH 2/2] landlock: transpose the layer masks data structure Günther Noack
2025-12-31 23:14   ` Justin Suess
2026-01-09 16:18   ` Mickaël Salaün
2026-01-11 20:51     ` Günther Noack
2026-01-11 21:52   ` Günther Noack
2026-01-21 22:16     ` Mickaël Salaün
2026-01-21  0:26   ` Tingmao Wang
2026-01-21 22:27     ` Mickaël Salaün
2026-01-21 23:08     ` Justin Suess
2026-01-23 22:11     ` Günther Noack
2026-01-21 22:22   ` Mickaël Salaün
     [not found]     ` <20260123.13e99fee0197@gnoack.org>
2026-01-28 21:49       ` Mickaël Salaün
2026-01-25  1:52   ` Tingmao Wang
2025-12-30 10:48 ` [RFC PATCH 0/2] landlock: Refactor layer masks Günther Noack
2026-01-09 15:59   ` Mickaël Salaün
2026-01-11 21:40     ` Günther Noack

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox