From: sashiko-bot@kernel.org
To: "Andi Kleen" <ak@kernel.org>
Cc: linux-perf-users@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 03/11] ptwrite uprobes: Add a sample module to exercise interface
Date: Thu, 17 Sep 2026 23:20:21 +0000 [thread overview]
Message-ID: <20260917232021.E71D21F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260917230127.924985-4-ak@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] samples/uprobe: dead code in parse_probe_args due to loop invariants
--
commit 77dc8c84b5d7c061149ad9471b13f1d9dabd7049
Author: Andi Kleen <ak@kernel.org>
ptwrite uprobes: Add a sample module to exercise interface
This adds a test module and userspace target program for uprobes ptwrite.
The module can be configured via parameters to register a ptwrite uprobe at
a specified offset and emit live registers or immediates into an Intel PT
stream. It is intended strictly for testing the interface.
> diff --git a/samples/uprobe-ptwrite/uprobe_ptwrite_test.c b/samples/uprobe-ptwrite/uprobe_ptwrite_test.c
> new file mode 100644
> --- /dev/null
> +++ b/samples/uprobe-ptwrite/uprobe_ptwrite_test.c
[ ... ]
> +static int parse_probe_args(void)
> +{
> + char *s, *p, *tok;
> + unsigned int n = 0;
> +
> + s = kstrdup(args, GFP_KERNEL);
> + if (!s)
> + return -ENOMEM;
> +
> + p = s;
> + while ((tok = strsep(&p, ",")) != NULL) {
> + struct uprobe_ptwrite_arg *a;
[ ... ]
> + if (tok[0] == 'r') {
[ ... ]
> + } else if (tok[0] == 'i') {
[ ... ]
> + } else {
> + pr_err("bad arg '%s'\n", tok);
> + goto err;
> + }
> + n++;
> + }
> + if (!n) {
> + pr_err("need 1..%d args\n", UPROBE_PTWRITE_MAX_ARGS);
> + goto err;
> + }
[Severity: Low]
Is this zero-argument check reachable?
Because p is initialized to a non-NULL string returned by kstrdup(), the
strsep() loop will always execute at least once. Inside the loop, any
invalid token triggers a goto err, skipping this check entirely. If the
token is valid, n is incremented.
Normal termination of the loop seems to guarantee that n >= 1, making this
condition structurally dead code.
> + desc.nargs = n;
> + kfree(s);
> + return 0;
> +err:
> + kfree(s);
> + return -EINVAL;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917230127.924985-2-ak@kernel.org?part=3
next prev parent reply other threads:[~2026-09-17 23:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 23:00 ptwrite uprobes v2 Andi Kleen
2026-09-17 23:00 ` [RFC PATCH v2 01/11] ptwrite uprobes: Add infrastructure for ptwrite uprobes Andi Kleen
2026-09-17 23:19 ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 02/11] ptwrite uprobes: Add minimal low level support for x86 Andi Kleen
2026-09-17 23:25 ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 03/11] ptwrite uprobes: Add a sample module to exercise interface Andi Kleen
2026-09-17 23:20 ` sashiko-bot [this message]
2026-09-17 23:00 ` [RFC PATCH v2 04/11] ptwrite uprobes: Add support to tracing infrastructure Andi Kleen
2026-09-17 23:23 ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 05/11] ptwrite uprobes: Factor file-backed instruction reads Andi Kleen
2026-09-17 23:14 ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 06/11] ptwrite uprobes: Add basic memory references Andi Kleen
2026-09-17 23:17 ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 07/11] ptwrite uprobes: Add multinop support Andi Kleen
2026-09-17 23:22 ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 08/11] ptwrite uprobes: Support instruction punning Andi Kleen
2026-09-17 23:27 ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 09/11] ptwrite uprobes: Use atomic patching for multinop sites Andi Kleen
2026-09-17 23:32 ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 10/11] ptwrite uprobes: Add a tutorial and overview documentation Andi Kleen
2026-09-17 23:21 ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 11/11] ptwrite uprobes: Add kernel self tests Andi Kleen
2026-09-17 23:28 ` 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=20260917232021.E71D21F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ak@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@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