]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools/rv: Fix substring match when listing container monitors
authorGabriele Monaco <gmonaco@redhat.com>
Thu, 14 May 2026 15:20:43 +0000 (17:20 +0200)
committerGabriele Monaco <gmonaco@redhat.com>
Thu, 4 Jun 2026 14:44:25 +0000 (16:44 +0200)
When listing monitors within a specific container (rv list <container>),
the tool incorrectly matched monitors if the requested container name
was only a prefix of the actual container (e.g., 'rv list sche' would
incorrectly list monitors from 'sched:').

Fix this by ensuring the container name is an exact match and is
immediately followed by the ':' separator.

Fixes: eba321a16fc6 ("tools/rv: Add support for nested monitors")
Reviewed-by: Nam Cao <namcao@linutronix.de>
Link: https://lore.kernel.org/r/20260514152055.229162-3-gmonaco@redhat.com
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
tools/verification/rv/src/in_kernel.c

index 95eac9ab1484689162a3de0d93eca78e6a13f13c..e4f35940374f5ad4c5c73757fb6f30c5f9e8f5ec 100644 (file)
@@ -193,8 +193,12 @@ static int ikm_fill_monitor_definition(char *name, struct monitor *ikm, char *co
        nested_name = strstr(name, ":");
        if (nested_name) {
                /* it belongs in container if it starts with "container:" */
-               if (container && strstr(name, container) != name)
-                       return 1;
+               if (container) {
+                       int len = strlen(container);
+
+                       if (strncmp(name, container, len) || name[len] != ':')
+                               return 1;
+               }
                *nested_name = '/';
                ++nested_name;
                ikm->nested = 1;