mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
landlock: Allow TSYNC with LOG_SUBDOMAINS_OFF and fd=-1
LANDLOCK_RESTRICT_SELF_TSYNC does not allow
LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF with ruleset_fd=-1, preventing
a multithreaded process from atomically propagating subdomain log muting
to all threads without creating a domain layer. Relax the fd=-1
condition to accept TSYNC alongside LOG_SUBDOMAINS_OFF, and update the
documentation accordingly.
Add flag validation tests for all TSYNC combinations with ruleset_fd=-1,
and audit tests verifying both transition directions: muting via TSYNC
(logged to not logged) and override via TSYNC (not logged to logged).
Cc: Günther Noack <gnoack@google.com>
Cc: stable@vger.kernel.org
Fixes: 42fc7e6543 ("landlock: Multithreading support for landlock_restrict_self()")
Reviewed-by: Günther Noack <gnoack3000@gmail.com>
Link: https://lore.kernel.org/r/20260407164107.2012589-2-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
This commit is contained in:
@@ -512,10 +512,13 @@ SYSCALL_DEFINE2(landlock_restrict_self, const int, ruleset_fd, const __u32,
|
||||
|
||||
/*
|
||||
* It is allowed to set LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF with
|
||||
* -1 as ruleset_fd, but no other flag must be set.
|
||||
* -1 as ruleset_fd, optionally combined with
|
||||
* LANDLOCK_RESTRICT_SELF_TSYNC to propagate this configuration to all
|
||||
* threads. No other flag must be set.
|
||||
*/
|
||||
if (!(ruleset_fd == -1 &&
|
||||
flags == LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF)) {
|
||||
(flags & ~LANDLOCK_RESTRICT_SELF_TSYNC) ==
|
||||
LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF)) {
|
||||
/* Gets and checks the ruleset. */
|
||||
ruleset = get_ruleset_from_fd(ruleset_fd, FMODE_CAN_READ);
|
||||
if (IS_ERR(ruleset))
|
||||
@@ -537,9 +540,10 @@ SYSCALL_DEFINE2(landlock_restrict_self, const int, ruleset_fd, const __u32,
|
||||
|
||||
/*
|
||||
* The only case when a ruleset may not be set is if
|
||||
* LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF is set and ruleset_fd is -1.
|
||||
* We could optimize this case by not calling commit_creds() if this flag
|
||||
* was already set, but it is not worth the complexity.
|
||||
* LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF is set (optionally with
|
||||
* LANDLOCK_RESTRICT_SELF_TSYNC) and ruleset_fd is -1. We could
|
||||
* optimize this case by not calling commit_creds() if this flag was
|
||||
* already set, but it is not worth the complexity.
|
||||
*/
|
||||
if (ruleset) {
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user