From: sashiko-bot@kernel.org
Cc: linux-security-module@vger.kernel.org
Subject: Re: [PATCH v4 5/8] selftests/landlock: Add namespace restriction tests
Date: Fri, 02 Oct 2026 12:56:28 +0000 [thread overview]
Message-ID: <20261002125628.94DE41F00898@smtp.kernel.org> (raw)
In-Reply-To: <20261002124409.1277970-6-mic@digikod.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] selftests/landlock: Data truncation of 64-bit namespace flags in audit log string matching
--
commit 5fd29f953c165adc6df65241e36e43cef7dbf0ae
Author: Mickaël Salaün <mic@digikod.net>
selftests/landlock: Add namespace restriction tests
This commit adds extensive tests for the LANDLOCK_PERMISSION_NAMESPACE_USE
restriction, covering namespace creation and entry. It includes rule
validation, forward compatibility checks, layer stacking, and audit logging.
Link: https://patch.msgid.link/20260726161400.3010511-10-mic@digikod.net
> diff --git a/tools/testing/selftests/landlock/ns_test.c b/tools/testing/selftests/landlock/ns_test.c
> new file mode 100644
> index 0000000000000..6faafc110844d
> --- /dev/null
> +++ b/tools/testing/selftests/landlock/ns_test.c
[ ... ]
> +static int matches_log_ns_create(int audit_fd, __u64 ns_type)
> +{
> + static const char log_template[] = REGEX_LANDLOCK_PREFIX
> + " blockers=namespace\\.use namespace_type=0x%x namespace_id=0$";
> + char log_match[sizeof(log_template) + 10];
> + int log_match_len;
> +
> + log_match_len = snprintf(log_match, sizeof(log_match), log_template,
> + (unsigned int)ns_type);
[Severity: Low]
Does this format string risk truncating the ns_type value? The ns_type
parameter is a 64-bit __u64, but it is explicitly cast to unsigned int
and formatted with %x. If a namespace flag exceeding 32 bits is ever
tested, the upper 32 bits will be truncated, producing an incorrect audit
log match string and causing test failures.
> + if (log_match_len >= sizeof(log_match))
> + return -E2BIG;
> +
> + return audit_match_record(audit_fd, AUDIT_LANDLOCK_ACCESS, log_match,
> + NULL);
> +}
> +
> +static int matches_log_ns_setns(int audit_fd, __u64 ns_type, __u64 ns_id)
> +{
> + static const char log_template[] = REGEX_LANDLOCK_PREFIX
> + " blockers=namespace\\.use namespace_type=0x%x namespace_id=%llu$";
> + char log_match[sizeof(log_template) + 32];
> + int log_match_len;
> +
> + log_match_len = snprintf(log_match, sizeof(log_match), log_template,
> + (unsigned int)ns_type,
> + (unsigned long long)ns_id);
[Severity: Low]
This seems to have the same truncation issue as matches_log_ns_create()
above. The 64-bit ns_type parameter is cast to a 32-bit unsigned int and
formatted with %x, which will drop the upper 32 bits.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261002124409.1277970-1-mic@digikod.net?part=5
next prev parent reply other threads:[~2026-10-02 12:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 12:43 [PATCH v4 0/8] Landlock: Namespace and capability control Mickaël Salaün
2026-10-02 12:43 ` [PATCH v4 1/8] landlock: Rename quiet_masks to quiet_access Mickaël Salaün
2026-10-02 12:50 ` sashiko-bot
2026-10-02 12:43 ` [PATCH v4 2/8] landlock: Wrap per-layer access masks in struct layer_config Mickaël Salaün
2026-10-02 12:49 ` sashiko-bot
2026-10-02 12:43 ` [PATCH v4 3/8] landlock: Enforce namespace use restrictions Mickaël Salaün
2026-10-02 12:52 ` sashiko-bot
2026-10-02 12:43 ` [PATCH v4 4/8] landlock: Enforce capability restrictions Mickaël Salaün
2026-10-02 12:53 ` sashiko-bot
2026-10-02 12:43 ` [PATCH v4 5/8] selftests/landlock: Add namespace restriction tests Mickaël Salaün
2026-10-02 12:56 ` sashiko-bot [this message]
2026-10-06 9:56 ` Mickaël Salaün
2026-10-02 12:43 ` [PATCH v4 6/8] selftests/landlock: Add capability " Mickaël Salaün
2026-10-02 12:53 ` sashiko-bot
2026-10-06 9:57 ` Mickaël Salaün
2026-10-02 12:44 ` [PATCH v4 7/8] samples/landlock: Add capability and namespace restriction support Mickaël Salaün
2026-10-02 12:53 ` sashiko-bot
2026-10-06 9:57 ` Mickaël Salaün
2026-10-02 12:44 ` [PATCH v4 8/8] landlock: Add documentation for capability and namespace restrictions Mickaël Salaün
2026-10-02 12:59 ` sashiko-bot
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=20261002125628.94DE41F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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