<div dir="ltr">Hello everyone.<br>We can use &#39;tstringsearch&#39; to taint labels to a string. I want to know if the origin string is tainted, what&#39;s the labels of each character of a string generated by the origin string.<br>Now I have changed the tstringsearch.cpp, if there are any characters in a string have been tainted before, display the labelset of the string rather than taint on it.<br>This is what I have done:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><br>diff --git a/qemu/panda_plugins/tstringsearch/tstringsearch.cpp b/qemu/panda_plugins/tstringsearch/tstringsearch.cpp<br>index ab4f21e..528b510 100644<br>--- a/qemu/panda_plugins/tstringsearch/tstringsearch.cpp<br>+++ b/qemu/panda_plugins/tstringsearch/tstringsearch.cpp<br>@@ -55,6 +55,8 @@ void uninit_plugin(void *);<br> <br> }<br> <br>+extern Shad *shadow;<br>+<br> #ifdef CONFIG_SOFTMMU<br> <br> bool tstringsearch_label_on = true;<br>@@ -146,6 +148,32 @@ void tstringsearch_match(CPUState *env, target_ulong pc, target_ulong addr,<br>     // yes, we can get this right. but, meh.<br>     if ((memcmp((char *)thestring, (char *)matched_string, matched_string_length-1)) == 0) {<br>         printf (&quot;tstringsearch: string in memory @ 0x%lx\n&quot;, (long unsigned int) p);    <br>+<br>+        bool tainted = false;<br>+        for (unsigned i=0; i&lt;matched_string_length; i++) {<br>+            target_ulong va = p + i;<br>+            target_phys_addr_t pa = cpu_get_phys_addr(cpu_single_env, va);<br>+            if (taint2_query_ram(pa)) {<br>+                tainted = true;<br>+                break;<br>+            }<br>+        }<br>+        if (tainted) {<br>+            printf (&quot;Tainted\n&quot;);<br>+            for (unsigned i=0; i&lt;matched_string_length; i++) {<br>+                printf (&quot;%d:&quot;, i);<br>+                target_ulong va = p + i;<br>+                target_phys_addr_t pa = cpu_get_phys_addr(cpu_single_env, va);<br>+                tp_ls_ram_iter(shadow, pa, [](uint32_t el, void *stuff) -&gt;int {<br>+                                printf (&quot;%d,&quot;, el);<br>+                                return 0;<br>+                            }, NULL);<br>+                printf (&quot;\n&quot;);<br>+            }<br>+            printf (&quot;\n&quot;);<br>+            return;<br>+        }<br>+<br>         // ok this is ugly.  save pc, buffer addr and len<br>         the_pc = pc;<br>         the_buf = p;<br><br></blockquote>Now I have met two problems:<br>1. &#39;shadow&#39; is a global variable, but because plugins are compiled separately, the linker can&#39;t assign right address to &#39;shadow&#39; here.<br>2. &#39;tp_ls_ram_iter&#39; is declared in taint2.h, and it is written in c++, so I can&#39;t import it with &#39;extern &quot;C&quot;&#39;.<br><br>How to solve it, or how to change my code to make it works?<br><br></div>