Skip to content

Commit

Permalink
Blocked blacklisted dlls if the module or file name is blacklisted.
Browse files Browse the repository at this point in the history
BUG=

Review URL: https://codereview.chromium.org/1248863004

Cr-Commit-Position: refs/heads/master@{#341966}
  • Loading branch information
csharp authored and Commit bot committed Aug 5, 2015
1 parent 651dab2 commit febf078
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions chrome_elf/blacklist/blacklist_interceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<HMODULE>(*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);
}
}

Expand Down

0 comments on commit febf078

Please sign in to comment.