Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# Area: Security
# @TravisEz13 @PaulHigin
src/System.Management.Automation/security/wldpNativeMethods.cs @TravisEz13 @PaulHigin

# Area: Documentation
.github/ @joeyaiello @TravisEz13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ public static SystemEnforcementMode GetLockdownPolicy(string path, SafeHandle ha
private static SystemEnforcementMode GetWldpPolicy(string path, SafeHandle handle)
{
// If the WLDP assembly is missing (such as windows 7 or down OS), return default/None to skip WLDP validation
if (s_hadMissingWldpAssembly || !IO.File.Exists(IO.Path.Combine(Environment.SystemDirectory, "wldp.dll")))
if (s_hadMissingWldpAssembly)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still needed for Operating System before Windows 10

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I feel this is the right fix. We catch the DllNotFoundException and set the s_hadMissingWldpAssembly field there. I don't see a need to check it every time at the top of the method.

Copy link
Collaborator Author

@iSazonov iSazonov Jul 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is already in the PR description.

I just do not understand why the security fix (mentioned in related issue) led to this problem if it is a long-standing code? Or is there still another problem?

Update: It seems wldp.dll is more slow after the security fix
After remove the extra file check we have for debug compilation:
image

image

for release compilation:
image

image

Output from test script is:

Without bp:     150
With bp:        1041

So we have still a noticeable delay in wldp.dll.
Is it acceptable to cache policy for each path or MSFT team will investigate wldp internally? For Pester scenario we can get a very large cache.

{
s_hadMissingWldpAssembly = true;
return s_cachedWldpSystemPolicy.GetValueOrDefault(SystemEnforcementMode.None);
}

Expand Down