From: "Mickaël Salaün" <mic@digikod.net>
To: Tingmao Wang <m@maowtm.org>
Cc: "Günther Noack" <gnoack@google.com>,
"Justin Suess" <utilityemal77@gmail.com>,
"Jan Kara" <jack@suse.cz>, "Abhinav Saxena" <xandfury@gmail.com>,
linux-security-module@vger.kernel.org
Subject: Re: [PATCH v4 03/10] landlock: Suppress logging when quiet flag is present
Date: Fri, 19 Dec 2025 15:27:35 +0100 [thread overview]
Message-ID: <20251219.ahn3aiJuKahb@digikod.net> (raw)
In-Reply-To: <eb86863b-53b0-460b-b223-84dd31d765b9@maowtm.org>
On Sun, Nov 23, 2025 at 09:01:47PM +0000, Tingmao Wang wrote:
> On 11/21/25 15:27, Mickaël Salaün wrote:
> > On Sun, Nov 16, 2025 at 09:59:33PM +0000, Tingmao Wang wrote:
> >> [...]
> >> /**
> >> * landlock_log_denial - Create audit records related to a denial
> >> *
> >> * @subject: The Landlock subject's credential denying an action.
> >> * @request: Detail of the user space request.
> >> + * @rule_flags: The flags for the matched rule, or no_rule_flags (zero) if
> >> + * this is a scope request (no particular object involved).
> >> */
> >> void landlock_log_denial(const struct landlock_cred_security *const subject,
> >> - const struct landlock_request *const request)
> >> + const struct landlock_request *const request,
> >> + const struct collected_rule_flags rule_flags)
> >
> > It would be simpler and limit code change to move rule_flags/quiet_flags
> > into struct landlock_request, which means we can also remove
> > no_rule_flags.
>
> That's true, I can do that. In fact this way we also don't have to have 2
> extra parameters for is_access_to_paths_allowed - it can just operate on
> log_request_parent{1,2}->rule_flags. However I do see that
> landlock_request is intended to only be used by audit/logging code (and
> there is a comment in audit.h about not using it outside CONFIG_AUDIT to
> enable it to be optimized away, although testing a fresh build on next it
> doesn't look like it is taken out of vmlinux if compiled without
> CONFIG_AUDIT).
The log_request_parent* are indeed not elided. I sent a patch to fix
that: https://lore.kernel.org/r/20251219142302.744917-2-mic@digikod.net
> While this is fine for the purpose of this series as the
> quiet flag only affects audit logging, I wonder if this might cause a
> problem when we want to add more flags that might not be related to audit
> (e.g. Justin's LANDLOCK_ADD_RULE_NO_INHERIT).
>
> Alternatively maybe is_access_to_paths_allowed can still take extra
> parameters for rule flags, and we can make it so that the new rule_flags
> field in landlock_request is only assigned to right before
> landlock_log_denial, not from is_access_to_paths_allowed? (I won't do
> this for v5 which I will send in a minute)
Yes, we should store the rule flags in landlock_request struct when this
in only required for audit. In any case, we should always be able to
build without CONFIG_AUDIT, and in this case the stack frame should not
include landlock_request. So in your last patch series, because
landlock_request's rule flags are referenced by standalone pointers,
landlock_requset cannot be elided.
>
> >
> >> {
> >> struct audit_buffer *ab;
> >> struct landlock_hierarchy *youngest_denied;
> >> size_t youngest_layer;
> >> - access_mask_t missing;
> >> + access_mask_t missing, quiet_mask;
> >> + bool object_quiet_flag = false, quiet_applicable_to_access = false;
> >>
> >> if (WARN_ON_ONCE(!subject || !subject->domain ||
> >> !subject->domain->hierarchy || !request))
> >> @@ -409,10 +586,13 @@ void landlock_log_denial(const struct landlock_cred_security *const subject,
> >> youngest_layer = get_denied_layer(
> >> subject->domain, &missing, request->layer_masks,
> >> request->layer_masks_size);
> >> + object_quiet_flag = !!(rule_flags.quiet_masks & BIT(youngest_layer));
> >> } else {
> >> youngest_layer = get_layer_from_deny_masks(
> >> &missing, request->all_existing_optional_access,
> >> - request->deny_masks);
> >> + request->deny_masks,
> >> + request->quiet_optional_accesses,
> >> + &object_quiet_flag);
> >> }
> >> youngest_denied =
> >> get_hierarchy(subject->domain, youngest_layer);
next prev parent reply other threads:[~2025-12-19 14:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-16 21:59 [PATCH v4 00/10] Implement LANDLOCK_ADD_RULE_QUIET Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 01/10] landlock: Add a place for flags to layer rules Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 02/10] landlock: Add API support and docs for the quiet flags Tingmao Wang
2025-11-21 15:27 ` Mickaël Salaün
2025-11-23 21:00 ` Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 03/10] landlock: Suppress logging when quiet flag is present Tingmao Wang
2025-11-21 15:27 ` Mickaël Salaün
2025-11-23 21:01 ` Tingmao Wang
2025-12-19 14:27 ` Mickaël Salaün [this message]
2025-11-23 17:01 ` [PATCH v4 00/10] Implement LANDLOCK_ADD_RULE_QUIET Justin Suess
2025-11-23 21:03 ` Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 04/10] landlock: Fix wrong type usage Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 05/10] samples/landlock: Add quiet flag support to sandboxer Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 06/10] selftests/landlock: Replace hard-coded 16 with a constant Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 07/10] selftests/landlock: add tests for quiet flag with fs rules Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 08/10] selftests/landlock: add tests for quiet flag with net rules Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 09/10] selftests/landlock: Add tests for quiet flag with scope Tingmao Wang
2025-11-16 21:59 ` [PATCH v4 10/10] selftests/landlock: Add tests for invalid use of quiet flag Tingmao Wang
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=20251219.ahn3aiJuKahb@digikod.net \
--to=mic@digikod.net \
--cc=gnoack@google.com \
--cc=jack@suse.cz \
--cc=linux-security-module@vger.kernel.org \
--cc=m@maowtm.org \
--cc=utilityemal77@gmail.com \
--cc=xandfury@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).