i386: Check CF_RETURN bit in ix86_expand_epilogue
Fixes i386 prologue generation to correctly check for Control-Flow Enforcement Technology (CET) return protection.
The i386 epilogue generation code now correctly checks the CF_RETURN bit within flag_cf_protection. Previously, it only checked if flag_cf_protection was non-zero, which could lead to incorrect assumptions about CET protection being enabled. This fix ensures that indirect jumps for EH returns and stack adjustments are only used when CF_RETURN is explicitly set, resolving a bug where CET features might be incorrectly inferred.
In Details
This commit corrects ix86_expand_epilogue to properly check the CF_RETURN bit in flag_cf_protection. Previously, any non-zero value of flag_cf_protection (which is a bitmask for various CET features like CF_BRANCH, CF_SET, CF_CHECK) was treated as enabling CET return protection. This change ensures that indirect jumps for EH returns and pro_epilogue_adjust_stack calls are contingent on CF_RETURN being explicitly set, preventing incorrect code generation when only other CET bits are active.
- CET
- Control-Flow Enforcement Technology, a security feature in x86 processors that helps protect against control-flow hijacking attacks by adding hardware checks for indirect branches and calls.
- EH return
- Exception Handling return. In C++, this refers to the mechanism used to unwind the stack and transfer control back to a previous execution point when an exception is thrown.
- indirect jump
- A jump instruction whose target address is determined at runtime, typically by loading the address from a register or memory location, as opposed to a direct jump where the target address is fixed in the instruction.