diff --git a/include/interfaces/SMPDBInterface.h b/include/interfaces/SMPDBInterface.h index 73d19ed3b6a6a6ea3ff68a1f4c165a540558bb22..ddb4700842d6ab6857a3b30918be88244dff0dd7 100644 --- a/include/interfaces/SMPDBInterface.h +++ b/include/interfaces/SMPDBInterface.h @@ -163,6 +163,10 @@ extern unsigned long SCCPConstantOutgoingArgWriteCount; // Counter for max # of basic blocks seen in one function. extern unsigned long STARS_MaxBlockCount; +// Counters for safe and unsafe indirect memory writes. +extern unsigned long STARS_SafeIndirectMemWriteCount; +extern unsigned long STARS_UnsafeIndirectMemWriteCount; + // strings for printing ZST_SysCallType extern const char *CallTypeNames[4]; diff --git a/src/base/SMPDBInterface.cpp b/src/base/SMPDBInterface.cpp index 395c05e0074b7c7c0403ea8c115e51927af7b8cb..c1cb9905ce464a4f654ba194bad14ff0d7b582fb 100644 --- a/src/base/SMPDBInterface.cpp +++ b/src/base/SMPDBInterface.cpp @@ -112,6 +112,10 @@ unsigned long SCCPConstantOutgoingArgWriteCount; // Counter for max # of basic blocks seen in one function. unsigned long STARS_MaxBlockCount; +// Counters for safe and unsafe indirect memory writes. +unsigned long STARS_SafeIndirectMemWriteCount; +unsigned long STARS_UnsafeIndirectMemWriteCount; + // strings for printing ZST_SysCallType const char *CallTypeNames[4] = { "Unrestricted", "High-Privilege", "File-Access", "Network-Access" }; diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index 711413e2b2d60a519e9086c0bd201026f95217aa..6e8a40fbd135446d2245bf504d5702b48cf0ba56 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -5480,6 +5480,10 @@ void SMPFunction::AliasAnalysis(void) { if (CurrInst->DetectUnsafeMemWrite()) { this->HasUnsafeIndirectWrites = true; CurrInst->SetUnsafeMemWrite(); + ++STARS_UnsafeIndirectMemWriteCount; + } + else { + ++STARS_SafeIndirectMemWriteCount; } } } // end for all insts in block @@ -8771,9 +8775,13 @@ void SMPFunction::MarkFunctionSafe() { this->DetectMultiEntryFunction(); - bool UnsafeReturnAddr = (Unsafe || AccessesReturnAddress || WritesAboveLocalFrameIndirect || HasIndirectGlobalWrite - || HasIndirectWrite || (!this->AnalyzedSP) || this->MultipleEntryPoints); +#if 1 + bool UnsafeReturnAddr = (Unsafe || AccessesReturnAddress || this->HasUnsafeIndirectWrites || (!this->AnalyzedSP) || this->MultipleEntryPoints); +#else + bool UnsafeReturnAddr = (Unsafe || AccessesReturnAddress || WritesAboveLocalFrameIndirect || HasIndirectGlobalWrite + || HasIndirectWrite || (!this->AnalyzedSP) || this->MultipleEntryPoints); +#endif // We have conditions that cause fast returns to be unsafe even though the return address is safe. if (this->PossibleIndirectCallTarget) { SMP_msg("INFO: Function at %lx becoming unsafe for fast returns because it is indirect call target.\n", (unsigned long) this->GetFirstFuncAddr()); diff --git a/src/base/SMPProgram.cpp b/src/base/SMPProgram.cpp index fbd393763394b241cc2f85d71a93d2757063d94c..b51522f13cdbdc4bc8d29787c74a9633cc60159b 100644 --- a/src/base/SMPProgram.cpp +++ b/src/base/SMPProgram.cpp @@ -661,6 +661,8 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn SMP_msg("Total outarg writes analyzed: %lu\n", SCCPOutgoingArgWriteCount); SMP_msg("Total constant outarg writes analyzed: %lu\n", SCCPConstantOutgoingArgWriteCount); #endif + SMP_msg("Total safe indirect memory write instructions analyzed: %lu\n", STARS_SafeIndirectMemWriteCount); + SMP_msg("Total unsafe indirect memory write instructions analyzed: %lu\n", STARS_UnsafeIndirectMemWriteCount); #endif // not SMP_REDUCED_ANALYSIS SMP_msg("INFO: Maximum basic block count in one function: %lu\n", STARS_MaxBlockCount); diff --git a/tests/commit/trimmed-sorted-save-busybox.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-busybox.psexe.annot.REMOVED.git-id index 248762215aa3432476ce612ff3df6348eb30a216..1a31b0b6dc6ee8ed968514fc08ba82f4609d6f9f 100644 --- a/tests/commit/trimmed-sorted-save-busybox.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-busybox.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -8fcf829b0aea614a045f18b79d5cd1af0f42a373 \ No newline at end of file +4e085b7e1f21807a58e327a2e8c7388ece507424 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id index af79bfe944d3d9b7d2831701733929ea3800c6e8..27eeb649d54d23d8de0071e2ea1190edd2adb028 100644 --- a/tests/commit/trimmed-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -6769a740dd55de9d3fd999b2a0be05ad9d203ec5 \ No newline at end of file +adeae01a4a57c015571c5ad2e32a2c92ce7fd3c9 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-firefox-bin.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-firefox-bin.psexe.annot.REMOVED.git-id index 1678a94e0d4b0bd9d185726db51aae582d0efaf4..c6990c61a121ad7e065b2e9107e3e977a155c677 100644 --- a/tests/commit/trimmed-sorted-save-firefox-bin.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-firefox-bin.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -dea0304986e21e0a3135940bd258bd4b04602298 \ No newline at end of file +e95b19e6a02e205690c155aafb17591824edb68f \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-gedit.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-gedit.psexe.annot.REMOVED.git-id index 36eef6fe65a1c47130a3ab33da1bc909d8fee693..1798437a1cc90c19772776e3b92ac2df49b8a8dc 100644 --- a/tests/commit/trimmed-sorted-save-gedit.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-gedit.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -854aa2762cfdc0efc8b2841507eb625f20b9ebf7 \ No newline at end of file +efd5ed6614d429c296d502922108ef89a6a71026 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-gnome-calculator.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-gnome-calculator.psexe.annot.REMOVED.git-id index eb637bbb42abd9245666677930d6fc9261187c0c..aa8ef8d7f1a276a178282c606ab0a9f84540189e 100644 --- a/tests/commit/trimmed-sorted-save-gnome-calculator.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-gnome-calculator.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -67732409bd5a27f506c2b844365c67f45508c298 \ No newline at end of file +d6d7e5f536ad3407d2bcb1382e2d3df07106430b \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-gnome-keyring-daemon.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-gnome-keyring-daemon.psexe.annot.REMOVED.git-id index a390c886697d974b427758511fb13b8aa69a1a22..90d59ba330d8dc92ac7e5596864df8a10bb969af 100644 --- a/tests/commit/trimmed-sorted-save-gnome-keyring-daemon.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-gnome-keyring-daemon.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -a3de79a0c9ae76bb27b44e1b9e36879bde041cbe \ No newline at end of file +58dd348bd3fa94b255fbbf1add4d45f137d12d53 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-gnome-system-monitor.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-gnome-system-monitor.psexe.annot.REMOVED.git-id index 59682439d18291c89d9429ed8f0f3d312886e139..a98a61f57cf783b3b260691d95a6fa00281731d9 100644 --- a/tests/commit/trimmed-sorted-save-gnome-system-monitor.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-gnome-system-monitor.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -2f876970c4deabea5f6b246ac842e0d206b87ac2 \ No newline at end of file +eb65cb569bdc441e37212e5a2e0a92e8f6b70ac2 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-gnome-text-editor.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-gnome-text-editor.psexe.annot.REMOVED.git-id index 36eef6fe65a1c47130a3ab33da1bc909d8fee693..1798437a1cc90c19772776e3b92ac2df49b8a8dc 100644 --- a/tests/commit/trimmed-sorted-save-gnome-text-editor.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-gnome-text-editor.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -854aa2762cfdc0efc8b2841507eb625f20b9ebf7 \ No newline at end of file +efd5ed6614d429c296d502922108ef89a6a71026 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-httpd.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-httpd.psexe.annot.REMOVED.git-id index ea6d0ea319387c5d1249be7a83afbc4e90a55ce8..48106bc2517aa560e12fa60c4f7cf99575c5a4fc 100644 --- a/tests/commit/trimmed-sorted-save-httpd.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-httpd.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -395d74a10b1f4c4db053c37e189c8084e259bba2 \ No newline at end of file +e7af2cfb92a2b58fdccd732b391a9b87fe3fdd2f \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-less.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-less.psexe.annot.REMOVED.git-id index 30fe71ad40f4fb52196004b5ec72d567af05f9f0..4cafc1d249cdf493a5bc077154bbee5e3dbd03dd 100644 --- a/tests/commit/trimmed-sorted-save-less.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-less.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -a5cda7b5fdbd1b7211c0055b4d670675ad67824c \ No newline at end of file +ae507e5bf1ba0bcd134baa5feca3e652f375bae6 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-lt-svn.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-lt-svn.psexe.annot.REMOVED.git-id index f074a723081dcd6095a332fbc9ddbac23bca0c3b..90e3b967fd80e320b2558c6dc7c817f670a30987 100644 --- a/tests/commit/trimmed-sorted-save-lt-svn.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-lt-svn.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -e80baddf2cf30ff90b972e75661df67bb8c71e41 \ No newline at end of file +223c066767d7e485b46c2215f16fda7223e4167a \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-nginx.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-nginx.psexe.annot.REMOVED.git-id index 00918a651def2936dba793c6616878e7a41d241f..e88b480e740f8282f1a7a76c78aee1ae7d37dcc9 100644 --- a/tests/commit/trimmed-sorted-save-nginx.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-nginx.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -c3ea4f99f8fec1d41edb39491a905fc3110f6ebd \ No newline at end of file +5731ffceb4f891f2c27de7b81198e4b65b84fe01 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-openssl.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-openssl.psexe.annot.REMOVED.git-id index 0c23f78b9b8fd8872bc9924318ab87b8f1dbc4f3..b6197f16b10f6c417f47684852c76709e4980f1d 100644 --- a/tests/commit/trimmed-sorted-save-openssl.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-openssl.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -2ed6300ba667ca900d34519276f9c3b24e9f261d \ No newline at end of file +9ebea348b24d6b50510cca969ec10ca9d19cb041 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-synaptic.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-synaptic.psexe.annot.REMOVED.git-id index d423131369899b02b58c735cb9ef2996a1065dcd..b8bc3ab793fc0cb2fa0c80c15097e79d57b5188a 100644 --- a/tests/commit/trimmed-sorted-save-synaptic.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-synaptic.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -9293cfca47a9f6ae488aec03601314edf4f55ac7 \ No newline at end of file +e7ddc38eedbcf8b7d186c03d9715bda7e2cc5a82 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-xcalc.psexe.annot b/tests/commit/trimmed-sorted-save-xcalc.psexe.annot index 9e23d0b3aeafdea10f6e648e8fbeb3a760a178ec..259dfb434ac1ee486cff56e179e1b06ba82c6624 100644 --- a/tests/commit/trimmed-sorted-save-xcalc.psexe.annot +++ b/tests/commit/trimmed-sorted-save-xcalc.psexe.annot @@ -4118,7 +4118,7 @@ 402ff7 -4 INSTR LOCAL SafeReturn retn 403000 0 FUNC FRAMERESTORE 0 0 0 1 0 0 2 0 1 3 0 0 4 0 8 5 0 0 6 0 1 7 0 0 8 0 0 9 0 0 10 0 0 11 0 0 12 0 0 13 0 0 14 0 0 15 0 0 ZZ 403000 0 FUNC MMSAFENESS SAFE - 403000 126 FUNC GLOBAL sub_403000 FUNC_SAFE NOFP RET FUNC_LEAF 40307d + 403000 126 FUNC GLOBAL sub_403000 FUNC_UNSAFE NOFP RET FUNC_LEAF 40307d 403000 6 INSTR BELONGTO 403000 403000 6 INSTR DEADREGS EFLAGS RAX RDI ZZ mov edi, cs:dword_608820 403000 8 MEMORYHOLE STACK esp + 0 ReturnAddress @@ -4143,7 +4143,6 @@ 403024 6 INSTR DEADREGS EFLAGS XMM0 ZZ mov cs:dword_608780, eax 40302a 1 INSTR BELONGTO 403000 40302a 1 INSTR DEADREGS EFLAGS XMM0 ZZ retn - 40302a -4 INSTR LOCAL SafeReturn retn 403030 7 INSTR BELONGTO 403000 403030 7 INSTR DEADREGS EFLAGS RAX ZZ mov rax, cs:qword_608688 403037 7 INSTR BELONGTO 403000 @@ -4156,7 +4155,6 @@ 40304d 7 INSTR DEADREGS EFLAGS XMM0 ZZ mov cs:qword_608688, rax 403054 1 INSTR BELONGTO 403000 403054 1 INSTR DEADREGS EFLAGS XMM0 ZZ retn - 403054 -4 INSTR LOCAL SafeReturn retn 403058 10 INSTR BELONGTO 403000 403058 10 INSTR DEADREGS EFLAGS RSI XMM0 ZZ mov rsi, 7265206B63617473h 403058 -2 INSTR LOCAL n RSI ZZ NUMVia2ndSrcIMMEDNUM mov rsi, 7265206B63617473h @@ -4168,7 +4166,6 @@ 403076 7 INSTR DEADREGS EFLAGS XMM0 ZZ mov cs:s, rsi 40307d 1 INSTR BELONGTO 403000 40307d 1 INSTR DEADREGS EFLAGS XMM0 ZZ retn - 40307d -4 INSTR LOCAL SafeReturn retn 403080 0 FUNC FRAMERESTORE 0 0 1 1 0 0 2 0 0 3 0 0 4 0 8 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10 0 0 11 0 0 12 0 0 13 0 0 14 0 0 15 0 0 ZZ 403080 0 FUNC MMSAFENESS SAFE 403080 130 FUNC GLOBAL sub_403080 FUNC_SAFE NOFP RET FUNC_LEAF 403101 diff --git a/tests/commit/trimmed-sorted-save-xedit.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-xedit.psexe.annot.REMOVED.git-id index f0bdc3f0cbedfea3ad2334456b585bf50a9327c1..54e9e35b529b1cdb94c5d971789e8a4d0f987475 100644 --- a/tests/commit/trimmed-sorted-save-xedit.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-xedit.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -cc363ea4069ff47e6563819311a707acb19da5b1 \ No newline at end of file +2bc21ac72bd9933a2e2d0beb44957943d3661d36 \ No newline at end of file