Skip to content

Commit 8c9489e

Browse files
authored
Update guard-enable-control-flow-guard.md
PR clarifies the options that need to be passed to both the linker and compiler in order to enable/disable CFG.
1 parent 07f8040 commit 8c9489e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/build/reference/guard-enable-control-flow-guard.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ When the **`/guard:cf`** Control Flow Guard (CFG) option is specified, the compi
2424

2525
A common attack on software takes advantage of bugs in handling extreme or unexpected inputs. Carefully crafted input to the application may overwrite a location that contains a pointer to executable code. This technique can be used to redirect control flow to code controlled by the attacker. The CFG runtime checks don't fix the data corruption bugs in your executable. They instead make it more difficult for an attacker to use them to execute arbitrary code. CFG is a mitigation tool that prevents calls to locations other than function entry points in your code. It's similar to how Data Execution Prevention (DEP), [/GS](gs-buffer-security-check.md) stack checks, and [`/DYNAMICBASE`](dynamicbase-use-address-space-layout-randomization.md) and [/HIGHENTROPYVA](highentropyva-support-64-bit-aslr.md) address space layout randomization (ASLR) lower the chances that your code becomes an exploit vector.
2626

27-
The **`/guard:cf`** option must be passed to both the compiler and linker to build code that uses the CFG exploit mitigation technique. If your binary is built by using a single `cl` command, the compiler passes the option to the linker. If you compile and link separately, the option must be set on both the compiler and linker commands. The /DYNAMICBASE linker option is also required. To verify that your binary has CFG data, use the `dumpbin /headers /loadconfig` command. CFG-enabled binaries have `Guard` in the list of EXE or DLL characteristics, and Guard Flags include `CF Instrumented` and `FID table present`.
27+
To use CFG exploit mitigation technique the **`/guard:cf`** option must be passed to the compiler and correspondigly the option **`/GUARD:CF`** must be passed to the linker. To disable CFG exploit mitigation technique the **`/guard:cf-`** option must be passed to the compiler and correspondingly the option **`/GUARD:NO`** must be passed to the linker.
28+
29+
If your binary is built by using a single `cl` command, the compiler passes the option to the linker. If you compile and link separately, the option must be set on both the compiler and linker commands. The /DYNAMICBASE linker option is also required. To verify that your binary has CFG data, use the `dumpbin /headers /loadconfig` command. CFG-enabled binaries have `Guard` in the list of EXE or DLL characteristics, and Guard Flags include `CF Instrumented` and `FID table present`.
2830

2931
The **`/guard:cf`** option is incompatible with [`/ZI`](z7-zi-zi-debug-information-format.md) (Edit and Continue debug information) or [`/clr`](clr-common-language-runtime-compilation.md) (Common Language Runtime Compilation).
3032

0 commit comments

Comments
 (0)