From febf078507e3393ea2cd747fa7951fba00eba61f Mon Sep 17 00:00:00 2001 From: csharp Date: Wed, 5 Aug 2015 13:44:50 -0700 Subject: Blocked blacklisted dlls if the module or file name is blacklisted. BUG= Review URL: https://codereview.chromium.org/1248863004 Cr-Commit-Position: refs/heads/master@{#341966} --- chrome_elf/blacklist/blacklist_interceptions.cc | 33 ++++++++++++++----------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'chrome_elf') diff --git a/chrome_elf/blacklist/blacklist_interceptions.cc b/chrome_elf/blacklist/blacklist_interceptions.cc index 07825ec..339de1a 100644 --- a/chrome_elf/blacklist/blacklist_interceptions.cc +++ b/chrome_elf/blacklist/blacklist_interceptions.cc @@ -36,6 +36,9 @@ FARPROC GetNtDllExportByName(const char* export_name) { } int DllMatch(const base::string16& module_name) { + if (module_name.empty()) + return -1; + for (int i = 0; blacklist::g_troublesome_dlls[i] != NULL; ++i) { if (_wcsicmp(module_name.c_str(), blacklist::g_troublesome_dlls[i]) == 0) return i; @@ -194,25 +197,27 @@ NTSTATUS BlNtMapViewOfSectionImpl( if (module) { UINT image_flags; - base::string16 module_name(GetImageInfoFromLoadedModule( + base::string16 module_name_from_image(GetImageInfoFromLoadedModule( reinterpret_cast(*base), &image_flags)); - base::string16 file_name(GetBackingModuleFilePath(*base)); - if (module_name.empty() && (image_flags & sandbox::MODULE_HAS_CODE)) { - // If the module has no exports we retrieve the module name from the - // full path of the mapped section. - module_name = ExtractLoadedModuleName(file_name); + int blocked_index = DllMatch(module_name_from_image); + + // If the module name isn't blacklisted, see if the file name is different + // and blacklisted. + if (blocked_index == -1) { + base::string16 file_name(GetBackingModuleFilePath(*base)); + base::string16 module_name_from_file = ExtractLoadedModuleName(file_name); + + if (module_name_from_image != module_name_from_file) + blocked_index = DllMatch(module_name_from_file); } - if (!module_name.empty()) { - int blocked_index = DllMatch(module_name); - if (blocked_index != -1) { - DCHECK_NT(g_nt_unmap_view_of_section_func); - g_nt_unmap_view_of_section_func(process, *base); - ret = STATUS_UNSUCCESSFUL; + if (blocked_index != -1) { + DCHECK_NT(g_nt_unmap_view_of_section_func); + g_nt_unmap_view_of_section_func(process, *base); + ret = STATUS_UNSUCCESSFUL; - blacklist::BlockedDll(blocked_index); - } + blacklist::BlockedDll(blocked_index); } } -- cgit v1.1