Windows 10: To implement Retpoline function in c/c++ high level function for mitigating Spectre variant...

Discus and support To implement Retpoline function in c/c++ high level function for mitigating Spectre variant... in AntiVirus, Firewalls and System Security to solve the problem; I have a query on spectre insecurity threats to modern CPUs on Windows OS. CVE-2017-5715, also known as spectre variant 2. Branch target injection... Discussion in 'AntiVirus, Firewalls and System Security' started by Sachin Chavan, Jun 18, 2019.

  1. To implement Retpoline function in c/c++ high level function for mitigating Spectre variant...


    I have a query on spectre insecurity threats to modern CPUs on Windows OS.
    CVE-2017-5715, also known as spectre variant 2. Branch target injection spectre variant 2 can be
    mitigated using retpoline. I am unable to implement retpoline in c/c++ function. Can some one help?

    I have seen retpoline solutions implemented in low level assemble language instructions posted on internet sites .

    :)
     
    Sachin Chavan, Jun 18, 2019
    #1
  2. Brink Win User

    Mitigating Spectre variant 2 with Retpoline on Windows


    Source: Mitigating Spectre variant 2 with Retpoline on Windows - Microsoft Tech Community - 295618
     
    Brink, Jun 18, 2019
    #2
  3. ddelo Win User
    Enable Retpoline to mitigate Spectre variant 2 (CVE-2017-5715)


    Following the release of Cumulative Update KB4482887 Windows 10 v1809 Build 17763.348 there is a lot of discussion regarding the new Retpoline mitigation.
    This feature has been included in the KB4482887, but is disabled by default. In future updates, or the next Feature Update (only Microsoft knows when), the feature will be enabled by default on Windows 10 clients.

    So to shed some light in the issue, first we need to understand what Meltdown and Spectre, with all its variants are.

    The best source of information can be found in this Microsoft article “Windows client guidance for IT Pros to protect against speculative execution side-channel vulnerabilities”

    So to make a long story short, these are the most recently identified vulnerabilities, until the time this post is created:

    [table][tr][td]Public Name[/td] [td]CVE[/td] [td]Vulnerability[/td] [td]Exploit Name[/td] [/tr] [tr][td]Bounds Check Bypass[/td] [td]CVE-2017-5753[/td] [td]Spectre[/td] [td]Variant 1[/td] [/tr] [tr][td]Branch Target Injection[/td] [td]CVE-2017-5715[/td] [td]Spectre[/td] [td]Variant 2[/td] [/tr] [tr][td]Kernel Virtual Address shadow / Rogue Data Cache Load[/td] [td]CVE-2017-5754[/td] [td]Meltdown[/td] [td]Variant 3[/td] [/tr] [tr][td]Rogue System Register Read[/td] [td]CVE-2018-3640[/td] [td]Spectre-NG[/td] [td]Variant 3a[/td] [/tr] [tr][td]Speculative Store Bypass[/td] [td]CVE-2018-3639[/td] [td]Spectre-NG[/td] [td]Variant 4[/td] [/tr] [tr][td]L1 Terminal Fault[/td] [td]CVE-2018-3615, CVE-2018-3620, CVE-2018-3646[/td] [td][/td] [td]Foreshadow & Foreshadow-NG[/td] [/tr] [tr][td]Lazy FP State Restore[/td] [td]CVE-2018-3665[/td] [td]Spectre-NG[/td] [td][/td] [/tr] [tr][td]Bounds Check Bypass Store[/td] [td]CVE-2018-3693[/td] [td]Spectre-NG[/td] [td]Variant 1.1[/td] [/tr] [tr][td]Read-only protection bypass[/td] [td][/td] [td]Spectre[/td] [td]Variant 1.2[/td] [/tr] [/table]

    Get the required information
    1. To check your PC’s status against these vulnerabilities and mitigate them, please refer to the above “Windows client guidance for IT Pros to protect against speculative execution side-channel vulnerabilities” article, install and run the referenced in the article, Get-SpeculationControl PowerShell script.
    2. To check which is the recommended microcode revision for your CPU, refer to the latest intel® Microcode Revision Guidance.
    3. To find the CPUID (referenced in the above intel Guidance), as well as some other interesting CPU data, run the PowerShell script for CPU Information incl. CPUID and microcode revision.
    Mitigate the vulnerabilities
    To mitigate the vulnerabilities you must follow these simple steps:
    1. Check your PC’s manufacturer Support page, for an updated BIOS/UEFI. If there is one, download it and update your PC.
    2. If the manufacturer doesn’t provide an updated BIOS/UEFI for your PC (usually done for older PCs. It’s the manufacturer’s way of telling to buy a new one!), then look for the latest Microsoft Microcode Update for your Windows 10 version. Download it from the Windows Update catalog and apply it.
    How the microcode works:
    • At boot time, BIOS/UEFI loads the microcode from the firmware. This microcode comes preinstalled with your PC and is updated ONLY by a BIOS/UEFI update provided by the system manufacturer, based on code developed and made available by the CPU vendor (intel/AMD etc)
    • When the OS takes over, it checks the microcode loaded by the firmware to see if it’s up to date. If it is proceeds and leaves things as they are loaded by the BIOS/UEFI. If it’s not up to date, it supersedes the BIOS/UEFI loaded microcode by the latest one, that Windows 10 have via a recent update from Microsoft. That is now becoming the “Currently Running microcode”, which is newer than the one the CPU firmware has.
    • In any case this microcode is flushed upon system shutdown.
    Retpoline
    This is software code, developed by Google, to mitigate Spectre variant 2 (CVE-2017-5715), while providing some performance improvement by doing so, as in general the updated microcode revisions against the Spectre/Meltdown vulnerabilities tend to degrade performance.
    To enable Retpoline please follow the steps in the Windows Kernel Internals blog post: Mitigating Spectre variant 2 with Retpoline on Windows

    After enabling Retpoline, you will see an improvement in the performance, but don't expect anything major and certainly not performance degradation.

    A couple of interesting points:
    The two Registry entries, to be added or changed, as described in the above Windows Kernel Internals blog post, might exist or might not exist in your Registry.
    • They might exist, if at the early stages of the Spectre/Meltdown mitigation process, you had applied a Windows update, either because your BIOS/UEFI microcode was out-of-date and the manufacturer didn’t provide an updated one, based on CPU vendor code, or worse than that, you have an old CPU, for which the CPU vendor hasn't developed new microcode.
    • On the other hand, if you don’t have them, doesn’t mean that you’re not protected. It’s because either you applied a BIOS/UEFI update from your PC’s manufacturer, or you installed one of the recent (1803/1809) Microsoft provided microcode updates, which don’t create the Registry entries.
    To apply the Retpoline mitigation you have to add the FeatureSettingsOverride and FeatureSettingsOverrideMask entries in your Registry (if you don’t have them) or change the two entries in the Registry (if you already have them).

    1. If you don’t have them just open PowerShell as Administrator and run the following two commands:
      Code:
      Code:
      New-ItemProperty -Path 'Registry::\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management' -Name FeatureSettingsOverride -PropertyType DWord -Value 1024  New-ItemProperty -Path 'Registry::\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management' -Name FeatureSettingsOverrideMask -PropertyType DWord -Value 1024
      OR copy and paste the following in a text file. Save it, with an extension .reg and merge it in your Registry, by double-clicking it.
      Code:
      Code:
      Windows Registry Editor Version 5.00    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]  "FeatureSettingsOverride"=dword:00000400  "FeatureSettingsOverrideMask"=dword:00000400
    2. If you already have them, as the Windows Kernel Internals blog post says, you need to “bitwise OR” them, in other words add the hex value 400 to the one you already have.
      To do that find the Registry entries under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management key.
      Double click on each one of them, and after making sure that you have chosen “Hexadecimal” as Base, add the hex value 400 to the one you have. For example if the value you already had was 8 type 408, if it was 3, type 403. Click OK, close the Registry Editor and reboot.
      That’s it.


      To implement Retpoline function in c/c++ high level function for mitigating Spectre variant... [​IMG]

    Not for everybody
    The last thing you should have in mind is that not all CPUs are capable of the Retpoline mitigation.
    According to intel, the processors based on the Intel microarchitecture codename Skylake and subsequent models will not be able to use Retpoline. In this case adding/changing the above two Registry entries will just enable the BTIKernelImportOptimizationEnabled feature and leave the BTIKernelRetpolineEnabled as false.

    That’s it, so far.
    Hope to have helped you. *Smile
    Dimitri
     
    ddelo, Jun 18, 2019
    #3
  4. EdTittel Win User

    To implement Retpoline function in c/c++ high level function for mitigating Spectre variant...

    Mitigating Spectre variant 2 with Retpoline on Windows


    After this result from Get-SpeculationControlSetting, looks like my Skylake production PC is (mostly) safe:

    To implement Retpoline function in c/c++ high level function for mitigating Spectre variant... [​IMG]

    --Ed--

    See this MS Support Document to make sense of the output from Get-SpeculationControlSettings for your own PCs.
     
    EdTittel, Jun 18, 2019
    #4
Thema:

To implement Retpoline function in c/c++ high level function for mitigating Spectre variant...

Loading...
  1. To implement Retpoline function in c/c++ high level function for mitigating Spectre variant... - Similar Threads - implement Retpoline function

  2. Modern USB-C Speaker volume adjustment not functioning

    in Windows 10 Software and Apps
    Modern USB-C Speaker volume adjustment not functioning: Hi,Since upgrading to windows 11 my Modern USB-C speaker isn't functioning correctly. When using the volume adjust buttons on the device the volume adjusts on the surface laptop 4 top left of the screen but the sound output from the speaker doesn't change. Likewise using the...
  3. Search function in Win10 will not search C drive

    in Cortana
    Search function in Win10 will not search C drive: I've tried altering the search parameters with in the 'settings ' to include the C:/ drive and have tried rebuild and it still only searches mainly Bing and occasionally my files. Can I delete this and either download it again or is there anothr commercial app which does...
  4. function keys are being implemented automatically

    in Windows 10 BSOD Crashes and Debugging
    function keys are being implemented automatically: function keys are being implemented automatically as if it is pressed though it is not. Keys are working fine, all drivers of the device are also working fine. But as function keys are activated, Volume, Brightness keys are not working. Every hardware is fine. Factory reset...
  5. Enable Retpoline to mitigate Spectre variant 2 (CVE-2017-5715)

    in AntiVirus, Firewalls and System Security
    Enable Retpoline to mitigate Spectre variant 2 (CVE-2017-5715): Following the release of Cumulative Update KB4482887 Windows 10 v1809 Build 17763.348 there is a lot of discussion regarding the new Retpoline mitigation. This feature has been included in the KB4482887, but is disabled by default. In future updates, or the next Feature...
  6. Mitigating Spectre variant 2 with Retpoline on Windows

    in Windows 10 News
    Mitigating Spectre variant 2 with Retpoline on Windows: In January 2018, Microsoft released an advisory and security updates related to a newly discovered class of hardware vulnerabilities involving speculative execution side channels (known as Spectre and Meltdown) that affect AMD, ARM, and Intel CPUs to varying degrees. If you...
  7. Windows 10 19H1 reduces impact of Spectre Mitigation to noise level

    in Windows 10 News
    Windows 10 19H1 reduces impact of Spectre Mitigation to noise level: Earlier this year two major vulnerabilities were discovered which affected the core processes of the computer. Named as Spectre and Meltdown, these “speculative execution” vulnerabilities meant hackers could steal data by simply visiting a website. Though there were no known...
  8. KB4078130 Update to Disable Mitigation against Spectre, Variant 2

    in Windows 10 News
    KB4078130 Update to Disable Mitigation against Spectre, Variant 2: Critical Update to Disable Mitigation against Spectre, Variant 2 Applies to: Windows 7 Service Pack 1, Windows 8.1, Windows 10, Windows 10 Version 1511, Windows 10 Version 1607, Windows 10 Version 1703, Windows 10 version 1709, Windows Server 2008 R2 Standard, Windows...
  9. Spectre mitigations in MSVC

    in Windows 10 News
    Spectre mitigations in MSVC: Microsoft is aware of a new publicly disclosed class of vulnerabilities, called “speculative execution side-channel attacks,” that affect many operating systems and modern processors, including processors from Intel, AMD, and ARM. On the MSVC team, we’ve reviewed information...
  10. KB4078407 Update to enable mitigation against Spectre, Variant 2

    in Windows 10 News
    KB4078407 Update to enable mitigation against Spectre, Variant 2: This update does not provide protection against Spectre Variant 2. All it does is turn on protection if you had previously disabled it because of a bad BIOS update.

Users found this page by searching for:

  1. c/c logic to implement retpoline