From: Dan Carpenter <dan.carpenter@linaro.org>
To: "Mickaël Salaün" <mic@digikod.net>
Cc: linux-kselftest@vger.kernel.org
Subject: [bug report] selftests/landlock: Add tests for audit flags and domain IDs
Date: Wed, 28 May 2025 11:13:55 +0300 [thread overview]
Message-ID: <aDbFwyZ_fM-IO7sC@stanley.mountain> (raw)
Hello Mickaël Salaün,
Commit 6a500b22971c ("selftests/landlock: Add tests for audit flags
and domain IDs") from Mar 20, 2025 (linux-next), leads to the
following Smatch static checker warning:
tools/testing/selftests/landlock/audit.h:408 audit_init_filter_exe()
warn: unsigned 'filter->exe_len' is never less than zero.
tools/testing/selftests/landlock/audit.h
399 static int audit_init_filter_exe(struct audit_filter *filter, const char *path)
400 {
401 char *absolute_path = NULL;
402
403 /* It is assume that there is not already filtering rules. */
404 filter->record_type = AUDIT_EXE;
405 if (!path) {
406 filter->exe_len = readlink("/proc/self/exe", filter->exe,
407 sizeof(filter->exe) - 1);
--> 408 if (filter->exe_len < 0)
size_t can't be negative.
409 return -errno;
410
411 return 0;
412 }
413
414 absolute_path = realpath(path, NULL);
415 if (!absolute_path)
416 return -errno;
417
418 /* No need for the terminating NULL byte. */
419 filter->exe_len = strlen(absolute_path);
420 if (filter->exe_len > sizeof(filter->exe))
421 return -E2BIG;
422
423 memcpy(filter->exe, absolute_path, filter->exe_len);
424 free(absolute_path);
425 return 0;
426 }
regards,
dan carpenter
reply other threads:[~2025-05-28 8:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=aDbFwyZ_fM-IO7sC@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=linux-kselftest@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