From: Kees Cook <kees@kernel.org>
To: Sameeksha Sankpal <sameekshasankpal@gmail.com>
Cc: skhan@linuxfoundation.org, luto@amacapital.net, wad@chromium.org,
shuah@kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] selftests/seccomp: Improve error logging in get_proc_stat()
Date: Wed, 28 May 2025 09:36:28 -0700 [thread overview]
Message-ID: <202505280933.33EEDC4DC8@keescook> (raw)
In-Reply-To: <20250528010839.11594-1-sameekshasankpal@gmail.com>
On Wed, May 28, 2025 at 06:38:39AM +0530, Sameeksha Sankpal wrote:
> Use TH_LOG to report failure when reading /proc/<pid>/stat in
> get_proc_stat(), following kernel test framework conventions.
>
> Previously, printf() was used which is discouraged.
printf wasn't used previous, that was in your v1. :)
>
> Suggested-by: Kees Cook <kees@kernel.org>
>
No blank line here -- other tags should all be together with the S-o-b
line.
> Signed-off-by: Sameeksha Sankpal <sameekshasankpal@gmail.com>
> ---
> v1 -> v2:
> - Used TH_LOG instead of printf for error logging
> - Moved variable declaration to the top of the function
> - Applied review suggestion by Kees Cook
>
> tools/testing/selftests/seccomp/seccomp_bpf.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index d6a85d7b26da..0f12052ef1c7 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -4505,14 +4505,14 @@ static char get_proc_stat(struct __test_metadata *_metadata, pid_t pid)
> char proc_path[100] = {0};
> char status;
> char *line;
> + int rc;
>
> snprintf(proc_path, sizeof(proc_path), "/proc/%d/stat", pid);
> ASSERT_EQ(get_nth(_metadata, proc_path, 3, &line), 1);
> - int rc = get_nth(_metadata, proc_path, 3, &line);
> - if (rc != 1) {
> - printf("[ERROR] user_notification_fifo: failed to read stat for PID %d (rc=%d)\n", pid, rc);
> - }
> - ASSERT_EQ(rc, 1);
This patch is against your v1 patch -- it doesn't apply to the seccomp
tree as-is. Please rebase your v2 off of the upstream tree rather than
your v1.
> + rc = get_nth(_metadata, proc_path, 3, &line);
> + ASSERT_EQ(rc, 1) {
Indenting looks wrong here, double-check you're using tabs. (And please
use scripts/checkpatch.pl to check your patch for common errors.)
> + TH_LOG("user_notification_fifo: failed to read stat for PID %d (rc=%d)", pid, rc);
> + }
> status = *line;
> free(line);
Code-wise, it looks good. Please respin for a v3 and this change should
be good to land.
-Kees
--
Kees Cook
next prev parent reply other threads:[~2025-05-28 16:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-17 12:27 [PATCH] selftests/seccomp: report errno and add hints on failure Sameeksha Sankpal
2025-05-19 15:19 ` Kees Cook
2025-05-28 1:08 ` [PATCH v2] selftests/seccomp: Improve error logging in get_proc_stat() Sameeksha Sankpal
2025-05-28 16:36 ` Kees Cook [this message]
2025-05-29 22:55 ` [PATCH v3] selftests/seccomp: Fix indentation and rebase error logging patch Sameeksha Sankpal
[not found] ` <CAGZaOhe0++vMANe1cAXXz=Pt1pf3ZX1vk3U7c0nGRnGGkt8e3A@mail.gmail.com>
[not found] ` <66a49c4b-2008-4059-97aa-59d53fb91c31@linuxfoundation.org>
2025-11-25 4:04 ` Sameeksha Sankpal
2025-11-25 17:25 ` Shuah Khan
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=202505280933.33EEDC4DC8@keescook \
--to=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=sameekshasankpal@gmail.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=wad@chromium.org \
/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