Re: [RFC PATCH v2 03/11] ptwrite uprobes: Add a sample module to exercise interface
From: sashiko-bot@kernel.org
Date: 2026-09-17 23:20:23
Also in:
linux-perf-users
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 [off-list ref] 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.
quoted hunk ↗ jump to hunk
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