From: "Günther Noack" <gnoack@google.com>
To: "Mickaël Salaün" <mic@digikod.net>
Cc: linux-security-module@vger.kernel.org,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH v1] selftests/landlock: Fix readlink check
Date: Wed, 28 May 2025 16:48:54 +0200 [thread overview]
Message-ID: <aDciQt8aYcW5qrEZ@google.com> (raw)
In-Reply-To: <20250528144426.1709063-1-mic@digikod.net>
On Wed, May 28, 2025 at 04:44:25PM +0200, Mickaël Salaün wrote:
> The audit_init_filter_exe() helper incorrectly checks the readlink(2)
> error because an unsigned integer is used to store the result. Use a
> signed integer for this check.
>
> Cc: Günther Noack <gnoack@google.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/aDbFwyZ_fM-IO7sC@stanley.mountain
> Fixes: 6a500b22971c ("selftests/landlock: Add tests for audit flags and domain IDs")
> ---
> tools/testing/selftests/landlock/audit.h | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/landlock/audit.h b/tools/testing/selftests/landlock/audit.h
> index 18a6014920b5..b16986aa6442 100644
> --- a/tools/testing/selftests/landlock/audit.h
> +++ b/tools/testing/selftests/landlock/audit.h
> @@ -403,11 +403,12 @@ static int audit_init_filter_exe(struct audit_filter *filter, const char *path)
> /* It is assume that there is not already filtering rules. */
> filter->record_type = AUDIT_EXE;
> if (!path) {
> - filter->exe_len = readlink("/proc/self/exe", filter->exe,
> - sizeof(filter->exe) - 1);
> - if (filter->exe_len < 0)
> + int ret = readlink("/proc/self/exe", filter->exe,
> + sizeof(filter->exe) - 1);
> + if (ret < 0)
> return -errno;
>
> + filter->exe_len = ret;
> return 0;
> }
>
> --
> 2.49.0
>
Reviewed-by: Günther Noack <gnoack@google.com>
prev parent reply other threads:[~2025-05-28 14:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-28 14:44 [PATCH v1] selftests/landlock: Fix readlink check Mickaël Salaün
2025-05-28 14:48 ` Günther Noack [this message]
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=aDciQt8aYcW5qrEZ@google.com \
--to=gnoack@google.com \
--cc=dan.carpenter@linaro.org \
--cc=linux-security-module@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).