Skip to content

eBPF-based security platform

upatch: remove proof-only uprobe path length

Tobias Klauser8cb70c08c7d6
diff --git a/AGENTS.md b/AGENTS.md
index 71483171..0b835c5e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -92,6 +92,10 @@ CI runs them only once the change is on main. A proof that no longer
matches the code, or no longer holds, is a security bug: a threat's
fact box or a coverage row then claims an assurance the tree does not
have.
+Proofs must not add runtime state used only to carry proof bookkeeping.
+Derive the value from observable state in the harness, or state the
+invariant directly, so production code retains only state needed at
+runtime.
New documentation extends an existing page or adds one to its section's
toctree, and follows `Documentation/contribute/documentation/writing-docs.rst`. Only
diff --git a/testing/proofs/cbmc/upatch-prog-specs.c b/testing/proofs/cbmc/upatch-prog-specs.c
index 0c1d9177..794a8670 100644
--- a/testing/proofs/cbmc/upatch-prog-specs.c
+++ b/testing/proofs/cbmc/upatch-prog-specs.c
@@ -59,8 +59,9 @@ static void uprobe_valid(const struct prog_spec *s)
__u32 j;
__CPROVER_assert(s->uprobe_path && s->uprobe_path[0] == '/' &&
- strnlen(s->uprobe_path, s->uprobe_path_len + 1) ==
- s->uprobe_path_len, "an absolute path of its length");
+ strnlen(s->uprobe_path, UPATCH_UPROBE_PATH_MAX) <
+ UPATCH_UPROBE_PATH_MAX,
+ "an absolute, terminated path");
if (kind_is_uprobe_multi(s->kind))
__CPROVER_assert(!strchr(s->target, ',') && !strchr(s->target, '|'),
"a glob without separators");
diff --git a/testing/proofs/cbmc/upatch-uprobe-targets.c b/testing/proofs/cbmc/upatch-uprobe-targets.c
index 9a131941..d8687fa2 100644
--- a/testing/proofs/cbmc/upatch-uprobe-targets.c
+++ b/testing/proofs/cbmc/upatch-uprobe-targets.c
@@ -29,8 +29,9 @@ static void uprobe_valid(const struct prog_spec *s)
__u32 j;
__CPROVER_assert(s->uprobe_path && s->uprobe_path[0] == '/' &&
- strnlen(s->uprobe_path, s->uprobe_path_len + 1) ==
- s->uprobe_path_len, "an absolute path of its length");
+ strnlen(s->uprobe_path, UPATCH_UPROBE_PATH_MAX) <
+ UPATCH_UPROBE_PATH_MAX,
+ "an absolute, terminated path");
if (!kind_is_uprobe_multi(s->kind))
__CPROVER_assert(s->nr_uprobe_offsets == 1, "one offset for a uprobe");
__CPROVER_assert(s->build_id_len && s->build_id_len <=
@@ -55,7 +56,6 @@ void harness(void)
*/
__CPROVER_assume(kind_has_uprobe_target(entry.kind));
entry.uprobe_path = NULL;
- entry.uprobe_path_len = 0;
entry.build_id_len = 0;
entry.uprobe_offsets = NULL;
entry.nr_uprobe_offsets = 0;
diff --git a/testing/proofs/cbmc/upatch-writer-prog-specs.c b/testing/proofs/cbmc/upatch-writer-prog-specs.c
index a0c9f19c..6e601cf7 100644
--- a/testing/proofs/cbmc/upatch-writer-prog-specs.c
+++ b/testing/proofs/cbmc/upatch-writer-prog-specs.c
@@ -571,8 +571,7 @@ static void uprobe_target(const struct prog_spec *s,
{
__u32 i;
- __CPROVER_assert(s->uprobe_path_len == strlen(UPROBE_PATH) &&
- !strcmp(s->uprobe_path, UPROBE_PATH),
+ __CPROVER_assert(!strcmp(s->uprobe_path, UPROBE_PATH),
"the path the section names");
__CPROVER_assert(s->build_id_len == shape->build_id_len &&
!memcmp(s->build_id, resolved[nth].build_id,
diff --git a/util/upatch.c b/util/upatch.c
index 0b953562..71c35b5a 100644
--- a/util/upatch.c
+++ b/util/upatch.c
@@ -752,7 +752,6 @@ static int parse_uprobe_targets(const __u8 **pos, const __u8 *end, struct prog_s
spec->uprobe_path = xstrndup((const char *)cursor, path_len);
if (!spec->uprobe_path)
return -ENOMEM;
- spec->uprobe_path_len = path_len;
cursor += path_len;
memcpy(spec->build_id, cursor, build_id_len);
spec->build_id_len = build_id_len;
diff --git a/util/upatch.h b/util/upatch.h
index 13c60677..a521716b 100644
--- a/util/upatch.h
+++ b/util/upatch.h
@@ -163,7 +163,6 @@ struct prog_spec {
char target[UPATCH_ATTACH_TARGET_MAX];
char map[UPATCH_PROG_MAP_MAX];
char *uprobe_path;
- __u32 uprobe_path_len;
__u8 build_id[UPATCH_BUILD_ID_MAX];
__u32 build_id_len;
__u64 *uprobe_offsets;