Control-flow Enforcement (CET) is a new Intel processor feature that blocks
return/jump-oriented programming attacks. Details are in "Intel 64 and
IA-32 Architectures Software Developer's Manual" [1].
This is the second part of CET and enables Indirect Branch Tracking (IBT).
It is built on top of the shadow stack series.
Changes in v26:
- Rebase to Linus tree v5.12.
Changes in v25:
- Make updates to Kconfig and CPU feature flags for the removal of Kconfig
X86_CET and software-defined X86_FEATURE_CET.
- Update ENDBR definition.
- Rebase to Linus tree v5.12-rc7.
[1] Intel 64 and IA-32 Architectures Software Developer's Manual:
https://software.intel.com/en-us/download/intel-64-and-ia-32-
architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4
[2] Indirect Branch Tracking patches v25:
https://lore.kernel.org/r/20210415221734.32628-1-yu-cheng.yu@intel.com/
H.J. Lu (3):
x86/cet/ibt: Update arch_prctl functions for Indirect Branch Tracking
x86/vdso: Insert endbr32/endbr64 to vDSO
x86/vdso/32: Add ENDBR to __kernel_vsyscall entry point
Yu-cheng Yu (6):
x86/cet/ibt: Add Kconfig option for Indirect Branch Tracking
x86/cet/ibt: Add user-mode Indirect Branch Tracking support
x86/cet/ibt: Handle signals for Indirect Branch Tracking
x86/cet/ibt: Update ELF header parsing for Indirect Branch Tracking
x86/vdso: Introduce ENDBR macro
x86/vdso: Add ENDBR to __vdso_sgx_enter_enclave
arch/x86/Kconfig | 21 +++++++++
arch/x86/entry/vdso/Makefile | 4 ++
arch/x86/entry/vdso/vdso32/system_call.S | 2 +
arch/x86/entry/vdso/vsgx.S | 4 ++
arch/x86/include/asm/cet.h | 9 ++++
arch/x86/include/asm/disabled-features.h | 8 +++-
arch/x86/include/asm/vdso.h | 20 ++++++++-
arch/x86/include/uapi/asm/sigcontext.h | 1 +
arch/x86/kernel/Makefile | 1 +
arch/x86/kernel/cet_prctl.c | 5 +++
arch/x86/kernel/fpu/signal.c | 33 ++++++++++++--
arch/x86/kernel/ibt.c | 57 ++++++++++++++++++++++++
arch/x86/kernel/process_64.c | 8 ++++
13 files changed, 168 insertions(+), 5 deletions(-)
create mode 100644 arch/x86/kernel/ibt.c
--
2.21.0
Indirect Branch Tracking (IBT) provides protection against CALL-/JMP-
oriented programming attacks. It is active when the kernel has this
feature enabled, and the processor and the application support it.
When this feature is enabled, legacy non-IBT applications continue to
work, but without IBT protection.
Signed-off-by: Yu-cheng Yu <redacted>
Cc: Kees Cook <redacted>
---
v25:
- Make CONFIG_X86_IBT depend on CONFIG_X86_SHADOW_STACK.
arch/x86/Kconfig | 19 +++++++++++++++++++
arch/x86/include/asm/disabled-features.h | 8 +++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
An ELF file's .note.gnu.property indicates features the file supports.
The property is parsed at loading time and passed to arch_setup_elf_
property(). Update it for Indirect Branch Tracking.
Signed-off-by: Yu-cheng Yu <redacted>
Cc: Kees Cook <redacted>
---
v24:
- Update for changes introduced from splitting shadow stack and ibt.
arch/x86/Kconfig | 2 ++
arch/x86/kernel/process_64.c | 8 ++++++++
2 files changed, 10 insertions(+)
When an indirect CALL/JMP instruction is executed and before it reaches
the target, it is in 'WAIT_ENDBR' status, which can be read from
MSR_IA32_U_CET. The status is part of a task's status before a signal is
raised and preserved in the signal frame. It is restored for sigreturn.
IBT state machine is described in Intel SDM Vol. 1, Sec. 18.3.
Signed-off-by: Yu-cheng Yu <redacted>
Cc: Kees Cook <redacted>
---
v25:
- Move the addition of sc_ext.wait_endbr from an earlier shadow stack
patch to here.
- Change X86_FEATURE_CET to X86_FEATURE_SHSTK.
- Change wrmsrl() to wrmsrl_safe() and handle error.
v24:
- Update for changes from splitting shadow stack and ibt.
arch/x86/include/uapi/asm/sigcontext.h | 1 +
arch/x86/kernel/fpu/signal.c | 33 +++++++++++++++++++++++---
2 files changed, 31 insertions(+), 3 deletions(-)
@@ -149,6 +163,19 @@ static int restore_extra_state_to_xregs(struct sc_ext *sc_ext)if(cet->shstk_size)err=wrmsrl_safe(MSR_IA32_PL3_SSP,sc_ext->ssp);++if(err)+returnerr;++if(cet->ibt_enabled&&sc_ext->wait_endbr){+u64msr_val;++err=rdmsrl_safe(MSR_IA32_U_CET,&msr_val);+if(!err){+msr_val|=CET_WAIT_ENDBR;+err=wrmsrl_safe(MSR_IA32_U_CET,msr_val);+}+}#endifreturnerr;}
@@ -616,7 +643,7 @@ static unsigned long fpu__alloc_sigcontext_ext(unsigned long sp)*sigcontext_extisat:fpu+fpu_user_xstate_size+*FP_XSTATE_MAGIC2_SIZE,thenalignedto8.*/-if(cet->shstk_size)+if(cet->shstk_size||cet->ibt_enabled)sp-=(sizeof(structsc_ext)+8);#endifreturnsp;
From: "H.J. Lu" <redacted>
When Indirect Branch Tracking (IBT) is enabled, vDSO functions may be
called indirectly, and must have ENDBR32 or ENDBR64 as the first
instruction. The compiler must support -fcf-protection=branch so that it
can be used to compile vDSO.
Signed-off-by: H.J. Lu <redacted>
Signed-off-by: Yu-cheng Yu <redacted>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <redacted>
---
v24:
- Replace CONFIG_X86_CET with CONFIG_X86_IBT to reflect splitting of shadow
stack and ibt.
arch/x86/entry/vdso/Makefile | 4 ++++
1 file changed, 4 insertions(+)
ENDBR is a special new instruction for the Indirect Branch Tracking (IBT)
component of CET. IBT prevents attacks by ensuring that (most) indirect
branches and function calls may only land at ENDBR instructions. Branches
that don't follow the rules will result in control flow (#CF) exceptions.
ENDBR is a noop when IBT is unsupported or disabled. Most ENDBR
instructions are inserted automatically by the compiler, but branch
targets written in assembly must have ENDBR added manually.
Introduce ENDBR64/ENDBR32 macros.
Signed-off-by: Yu-cheng Yu <redacted>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
v25:
- Change from using the compiler's cet.h back to just ENDBR64/ENDBR32,
since the information is already known, and keep it simple.
arch/x86/include/asm/vdso.h | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
From: "H.J. Lu" <redacted>
ENDBR is a special new instruction for the Indirect Branch Tracking (IBT)
component of CET. IBT prevents attacks by ensuring that (most) indirect
branches and function calls may only land at ENDBR instructions. Branches
that don't follow the rules will result in control flow (#CF) exceptions.
ENDBR is a noop when IBT is unsupported or disabled. Most ENDBR
instructions are inserted automatically by the compiler, but branch
targets written in assembly must have ENDBR added manually.
Add that to __kernel_vsyscall entry point.
Signed-off-by: H.J. Lu <redacted>
Signed-off-by: Yu-cheng Yu <redacted>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <redacted>
---
arch/x86/entry/vdso/vdso32/system_call.S | 2 ++
1 file changed, 2 insertions(+)
ENDBR is a special new instruction for the Indirect Branch Tracking (IBT)
component of CET. IBT prevents attacks by ensuring that (most) indirect
branches and function calls may only land at ENDBR instructions. Branches
that don't follow the rules will result in control flow (#CF) exceptions.
ENDBR is a noop when IBT is unsupported or disabled. Most ENDBR
instructions are inserted automatically by the compiler, but branch
targets written in assembly must have ENDBR added manually.
Add ENDBR to __vdso_sgx_enter_enclave() branch targets.
Signed-off-by: Yu-cheng Yu <redacted>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
arch/x86/entry/vdso/vsgx.S | 4 ++++
1 file changed, 4 insertions(+)
From: David Laight <hidden> Date: 2021-04-28 14:48:40
From: Yu-cheng Yu
Sent: 27 April 2021 21:47
Control-flow Enforcement (CET) is a new Intel processor feature that blocks
return/jump-oriented programming attacks. Details are in "Intel 64 and
IA-32 Architectures Software Developer's Manual" [1].
...
Does this feature require that 'binary blobs' for out of tree drivers
be compiled by a version of gcc that adds the ENDBRA instructions?
If enabled for userspace, what happens if an old .so is dynamically
loaded?
Or do all userspace programs and libraries have to have been compiled
with the ENDBRA instructions?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Andy Lutomirski <luto@kernel.org> Date: 2021-04-28 14:52:39
On Wed, Apr 28, 2021 at 7:48 AM David Laight [off-list ref] wrote:
From: Yu-cheng Yu
quoted
Sent: 27 April 2021 21:47
Control-flow Enforcement (CET) is a new Intel processor feature that blocks
return/jump-oriented programming attacks. Details are in "Intel 64 and
IA-32 Architectures Software Developer's Manual" [1].
...
Does this feature require that 'binary blobs' for out of tree drivers
be compiled by a version of gcc that adds the ENDBRA instructions?
If enabled for userspace, what happens if an old .so is dynamically
loaded?
Or do all userspace programs and libraries have to have been compiled
with the ENDBRA instructions?
If you believe that the userspace tooling for the legacy IBT table
actually works, then it should just work. Yu-cheng, etc: how well
tested is it?
--Andy
On Wed, Apr 28, 2021 at 7:52 AM Andy Lutomirski [off-list ref] wrote:
On Wed, Apr 28, 2021 at 7:48 AM David Laight [off-list ref] wrote:
quoted
From: Yu-cheng Yu
quoted
Sent: 27 April 2021 21:47
Control-flow Enforcement (CET) is a new Intel processor feature that blocks
return/jump-oriented programming attacks. Details are in "Intel 64 and
IA-32 Architectures Software Developer's Manual" [1].
...
Does this feature require that 'binary blobs' for out of tree drivers
be compiled by a version of gcc that adds the ENDBRA instructions?
If enabled for userspace, what happens if an old .so is dynamically
loaded?
CET will be disabled by ld.so in this case.
quoted
Or do all userspace programs and libraries have to have been compiled
with the ENDBRA instructions?
Correct. ld and ld.so check this.
If you believe that the userspace tooling for the legacy IBT table
actually works, then it should just work. Yu-cheng, etc: how well
tested is it?
Legacy IBT bitmap isn't unused since it doesn't cover legacy codes
generated by legacy JITs.
--
H.J.
From: Andy Lutomirski <luto@kernel.org> Date: 2021-04-28 15:14:53
On Wed, Apr 28, 2021 at 7:57 AM H.J. Lu [off-list ref] wrote:
On Wed, Apr 28, 2021 at 7:52 AM Andy Lutomirski [off-list ref] wrote:
quoted
On Wed, Apr 28, 2021 at 7:48 AM David Laight [off-list ref] wrote:
quoted
From: Yu-cheng Yu
quoted
Sent: 27 April 2021 21:47
Control-flow Enforcement (CET) is a new Intel processor feature that blocks
return/jump-oriented programming attacks. Details are in "Intel 64 and
IA-32 Architectures Software Developer's Manual" [1].
...
Does this feature require that 'binary blobs' for out of tree drivers
be compiled by a version of gcc that adds the ENDBRA instructions?
If enabled for userspace, what happens if an old .so is dynamically
loaded?
CET will be disabled by ld.so in this case.
What if a program starts a thread and then dlopens a legacy .so?
quoted
quoted
Or do all userspace programs and libraries have to have been compiled
with the ENDBRA instructions?
Correct. ld and ld.so check this.
quoted
If you believe that the userspace tooling for the legacy IBT table
actually works, then it should just work. Yu-cheng, etc: how well
tested is it?
Legacy IBT bitmap isn't unused since it doesn't cover legacy codes
generated by legacy JITs.
How does ld.so decide whether a legacy JIT is in use?
From: David Laight <hidden> Date: 2021-04-28 15:33:42
From: Andy Lutomirski
Sent: 28 April 2021 16:15
On Wed, Apr 28, 2021 at 7:57 AM H.J. Lu [off-list ref] wrote:
quoted
On Wed, Apr 28, 2021 at 7:52 AM Andy Lutomirski [off-list ref] wrote:
quoted
On Wed, Apr 28, 2021 at 7:48 AM David Laight [off-list ref] wrote:
quoted
From: Yu-cheng Yu
quoted
Sent: 27 April 2021 21:47
Control-flow Enforcement (CET) is a new Intel processor feature that blocks
return/jump-oriented programming attacks. Details are in "Intel 64 and
IA-32 Architectures Software Developer's Manual" [1].
...
Does this feature require that 'binary blobs' for out of tree drivers
be compiled by a version of gcc that adds the ENDBRA instructions?
If enabled for userspace, what happens if an old .so is dynamically
loaded?
CET will be disabled by ld.so in this case.
What if a program starts a thread and then dlopens a legacy .so?
Or has shadow stack enabled and opens a .so that uses retpolines?
quoted
quoted
quoted
Or do all userspace programs and libraries have to have been compiled
with the ENDBRA instructions?
Correct. ld and ld.so check this.
quoted
If you believe that the userspace tooling for the legacy IBT table
actually works, then it should just work. Yu-cheng, etc: how well
tested is it?
Legacy IBT bitmap isn't unused since it doesn't cover legacy codes
generated by legacy JITs.
How does ld.so decide whether a legacy JIT is in use?
What if your malware just precedes its 'jump into the middle of a function'
with a %ds segment override?
I may have a real problem here.
We currently release program/library binaries that run on Linux
distributions that go back as far as RHEL6 (2.6.32 kernel era).
To do this everything is compiled on a userspace of the same vintage.
I'm not at all sure a new enough gcc to generate the ENDBR64 instructions
will run on the relevant system - and may barf on the system headers
even if we got it to run.
I really don't want to have to build multiple copies of everything.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
On Wed, Apr 28, 2021 at 7:57 AM H.J. Lu [off-list ref] wrote:
quoted
On Wed, Apr 28, 2021 at 7:52 AM Andy Lutomirski [off-list ref] wrote:
quoted
On Wed, Apr 28, 2021 at 7:48 AM David Laight [off-list ref] wrote:
quoted
From: Yu-cheng Yu
quoted
Sent: 27 April 2021 21:47
Control-flow Enforcement (CET) is a new Intel processor feature that blocks
return/jump-oriented programming attacks. Details are in "Intel 64 and
IA-32 Architectures Software Developer's Manual" [1].
...
Does this feature require that 'binary blobs' for out of tree drivers
be compiled by a version of gcc that adds the ENDBRA instructions?
David, do you mean kernel loadable drivers here? Do not worry about it
for now, since shadow stack/ibt is not enabled for kernel-mode yet.
quoted
quoted
quoted
If enabled for userspace, what happens if an old .so is dynamically
loaded?
CET will be disabled by ld.so in this case.
What if a program starts a thread and then dlopens a legacy .so?
quoted
quoted
quoted
Or do all userspace programs and libraries have to have been compiled
with the ENDBRA instructions?
Correct. ld and ld.so check this.
quoted
If you believe that the userspace tooling for the legacy IBT table
actually works, then it should just work. Yu-cheng, etc: how well
tested is it?
Legacy IBT bitmap isn't unused since it doesn't cover legacy codes
generated by legacy JITs.
How does ld.so decide whether a legacy JIT is in use?
Let me clarify. IBT bitmap isn't used at all. How dlopen() works
depends entirely on the tunable of glibc.cpu.x86_ibt. There are three
values: on, off, permissive. On is always on, and off is always off,
regardless of the .so having ibt or not. The default is "permissive,"
which turns off ibt upon dlopen a legacy .so. I hope this also answers
Andy's question above.
Yu-cheng
Sent: 28 April 2021 16:15
On Wed, Apr 28, 2021 at 7:57 AM H.J. Lu [off-list ref] wrote:
quoted
On Wed, Apr 28, 2021 at 7:52 AM Andy Lutomirski [off-list ref] wrote:
quoted
On Wed, Apr 28, 2021 at 7:48 AM David Laight [off-list ref] wrote:
quoted
From: Yu-cheng Yu
quoted
Sent: 27 April 2021 21:47
Control-flow Enforcement (CET) is a new Intel processor feature that blocks
return/jump-oriented programming attacks. Details are in "Intel 64 and
IA-32 Architectures Software Developer's Manual" [1].
...
Does this feature require that 'binary blobs' for out of tree drivers
be compiled by a version of gcc that adds the ENDBRA instructions?
If enabled for userspace, what happens if an old .so is dynamically
loaded?
CET will be disabled by ld.so in this case.
What if a program starts a thread and then dlopens a legacy .so?
Or has shadow stack enabled and opens a .so that uses retpolines?
When shadow stack is enabled, retpolines are not necessary. I don't
know if glibc has been updated for detection of this case. H.J.?
quoted
quoted
quoted
quoted
Or do all userspace programs and libraries have to have been compiled
with the ENDBRA instructions?
Correct. ld and ld.so check this.
quoted
If you believe that the userspace tooling for the legacy IBT table
actually works, then it should just work. Yu-cheng, etc: how well
tested is it?
Legacy IBT bitmap isn't unused since it doesn't cover legacy codes
generated by legacy JITs.
How does ld.so decide whether a legacy JIT is in use?
What if your malware just precedes its 'jump into the middle of a function'
with a %ds segment override?
Do you mean far jump? It is not tracked by ibt, which tracks near
indirect jump. The details can be found in Intel SDM.
I may have a real problem here.
We currently release program/library binaries that run on Linux
distributions that go back as far as RHEL6 (2.6.32 kernel era).
To do this everything is compiled on a userspace of the same vintage.
I'm not at all sure a new enough gcc to generate the ENDBR64 instructions
will run on the relevant system - and may barf on the system headers
even if we got it to run.
I really don't want to have to build multiple copies of everything.
This is likely OK. We have tested many combinations. Should you run
into any issue, please let glibc people know.
Thanks!
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
On Wed, Apr 28, 2021 at 9:25 AM Yu, Yu-cheng [off-list ref] wrote:
On 4/28/2021 8:33 AM, David Laight wrote:
quoted
From: Andy Lutomirski
quoted
Sent: 28 April 2021 16:15
On Wed, Apr 28, 2021 at 7:57 AM H.J. Lu [off-list ref] wrote:
quoted
On Wed, Apr 28, 2021 at 7:52 AM Andy Lutomirski [off-list ref] wrote:
quoted
On Wed, Apr 28, 2021 at 7:48 AM David Laight [off-list ref] wrote:
quoted
From: Yu-cheng Yu
quoted
Sent: 27 April 2021 21:47
Control-flow Enforcement (CET) is a new Intel processor feature that blocks
return/jump-oriented programming attacks. Details are in "Intel 64 and
IA-32 Architectures Software Developer's Manual" [1].
...
Does this feature require that 'binary blobs' for out of tree drivers
be compiled by a version of gcc that adds the ENDBRA instructions?
If enabled for userspace, what happens if an old .so is dynamically
loaded?
CET will be disabled by ld.so in this case.
What if a program starts a thread and then dlopens a legacy .so?
Or has shadow stack enabled and opens a .so that uses retpolines?
When shadow stack is enabled, retpolines are not necessary. I don't
know if glibc has been updated for detection of this case. H.J.?
quoted
quoted
quoted
quoted
quoted
Or do all userspace programs and libraries have to have been compiled
with the ENDBRA instructions?
Correct. ld and ld.so check this.
quoted
If you believe that the userspace tooling for the legacy IBT table
actually works, then it should just work. Yu-cheng, etc: how well
tested is it?
Legacy IBT bitmap isn't unused since it doesn't cover legacy codes
generated by legacy JITs.
How does ld.so decide whether a legacy JIT is in use?
What if your malware just precedes its 'jump into the middle of a function'
with a %ds segment override?
Do you mean far jump? It is not tracked by ibt, which tracks near
indirect jump. The details can be found in Intel SDM.
quoted
I may have a real problem here.
We currently release program/library binaries that run on Linux
distributions that go back as far as RHEL6 (2.6.32 kernel era).
To do this everything is compiled on a userspace of the same vintage.
I'm not at all sure a new enough gcc to generate the ENDBR64 instructions
will run on the relevant system - and may barf on the system headers
even if we got it to run.
I really don't want to have to build multiple copies of everything.
This is likely OK. We have tested many combinations. Should you run
into any issue, please let glibc people know.
If you have a Tiger Lake laptop, you can install the CET kernel on
Fedora 34 or Ubuntu 20.10/21.04.
--
H.J.
On Tue, Apr 27, 2021 at 01:47:12PM -0700, Yu-cheng Yu wrote:
Indirect Branch Tracking (IBT) provides protection against CALL-/JMP-
oriented programming attacks. It is active when the kernel has this
feature enabled, and the processor and the application support it.
When this feature is enabled, legacy non-IBT applications continue to
work, but without IBT protection.
Signed-off-by: Yu-cheng Yu <redacted>
On Tue, Apr 27, 2021 at 01:47:14PM -0700, Yu-cheng Yu wrote:
When an indirect CALL/JMP instruction is executed and before it reaches
the target, it is in 'WAIT_ENDBR' status, which can be read from
MSR_IA32_U_CET. The status is part of a task's status before a signal is
raised and preserved in the signal frame. It is restored for sigreturn.
IBT state machine is described in Intel SDM Vol. 1, Sec. 18.3.
Signed-off-by: Yu-cheng Yu <redacted>
On Tue, Apr 27, 2021 at 01:47:15PM -0700, Yu-cheng Yu wrote:
An ELF file's .note.gnu.property indicates features the file supports.
The property is parsed at loading time and passed to arch_setup_elf_
property(). Update it for Indirect Branch Tracking.
Signed-off-by: Yu-cheng Yu <redacted>
On Tue, Apr 27, 2021 at 01:47:17PM -0700, Yu-cheng Yu wrote:
From: "H.J. Lu" <redacted>
When Indirect Branch Tracking (IBT) is enabled, vDSO functions may be
called indirectly, and must have ENDBR32 or ENDBR64 as the first
instruction. The compiler must support -fcf-protection=branch so that it
can be used to compile vDSO.
If you respin this, you can maybe rephrase this since CONFIG_X86_IBT
has already tested for the compiler support.
Signed-off-by: H.J. Lu <redacted>
Signed-off-by: Yu-cheng Yu <redacted>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <redacted>
Reviewed-by: Kees Cook <redacted>
-Kees
quoted hunk
---
v24:
- Replace CONFIG_X86_CET with CONFIG_X86_IBT to reflect splitting of shadow
stack and ibt.
arch/x86/entry/vdso/Makefile | 4 ++++
1 file changed, 4 insertions(+)
On Tue, Apr 27, 2021 at 01:47:18PM -0700, Yu-cheng Yu wrote:
ENDBR is a special new instruction for the Indirect Branch Tracking (IBT)
component of CET. IBT prevents attacks by ensuring that (most) indirect
branches and function calls may only land at ENDBR instructions. Branches
that don't follow the rules will result in control flow (#CF) exceptions.
ENDBR is a noop when IBT is unsupported or disabled. Most ENDBR
instructions are inserted automatically by the compiler, but branch
targets written in assembly must have ENDBR added manually.
Introduce ENDBR64/ENDBR32 macros.
Signed-off-by: Yu-cheng Yu <redacted>
On Tue, Apr 27, 2021 at 01:47:19PM -0700, Yu-cheng Yu wrote:
From: "H.J. Lu" <redacted>
ENDBR is a special new instruction for the Indirect Branch Tracking (IBT)
component of CET. IBT prevents attacks by ensuring that (most) indirect
branches and function calls may only land at ENDBR instructions. Branches
that don't follow the rules will result in control flow (#CF) exceptions.
ENDBR is a noop when IBT is unsupported or disabled. Most ENDBR
instructions are inserted automatically by the compiler, but branch
targets written in assembly must have ENDBR added manually.
Add that to __kernel_vsyscall entry point.
Signed-off-by: H.J. Lu <redacted>
On Tue, Apr 27, 2021 at 01:47:17PM -0700, Yu-cheng Yu wrote:
From: "H.J. Lu" <redacted>
When Indirect Branch Tracking (IBT) is enabled, vDSO functions may be
called indirectly, and must have ENDBR32 or ENDBR64 as the first
instruction. The compiler must support -fcf-protection=branch so that it
can be used to compile vDSO.
Signed-off-by: H.J. Lu <redacted>
On Tue, Apr 27, 2021 at 01:47:19PM -0700, Yu-cheng Yu wrote:
From: "H.J. Lu" <redacted>
ENDBR is a special new instruction for the Indirect Branch Tracking (IBT)
component of CET. IBT prevents attacks by ensuring that (most) indirect
branches and function calls may only land at ENDBR instructions. Branches
that don't follow the rules will result in control flow (#CF) exceptions.
ENDBR is a noop when IBT is unsupported or disabled. Most ENDBR
instructions are inserted automatically by the compiler, but branch
targets written in assembly must have ENDBR added manually.
Add that to __kernel_vsyscall entry point.
Signed-off-by: H.J. Lu <redacted>
On Tue, Apr 27, 2021 at 01:47:20PM -0700, Yu-cheng Yu wrote:
ENDBR is a special new instruction for the Indirect Branch Tracking (IBT)
component of CET. IBT prevents attacks by ensuring that (most) indirect
branches and function calls may only land at ENDBR instructions. Branches
that don't follow the rules will result in control flow (#CF) exceptions.
ENDBR is a noop when IBT is unsupported or disabled. Most ENDBR
instructions are inserted automatically by the compiler, but branch
targets written in assembly must have ENDBR added manually.
Add ENDBR to __vdso_sgx_enter_enclave() branch targets.
Signed-off-by: Yu-cheng Yu <redacted>
On Tue, Apr 27, 2021 at 01:47:17PM -0700, Yu-cheng Yu wrote:
quoted
From: "H.J. Lu" <redacted>
When Indirect Branch Tracking (IBT) is enabled, vDSO functions may be
called indirectly, and must have ENDBR32 or ENDBR64 as the first
instruction. The compiler must support -fcf-protection=branch so that it
can be used to compile vDSO.
If you respin this, you can maybe rephrase this since CONFIG_X86_IBT
has already tested for the compiler support.
Yes, I will fix this. Thanks for reviewing!
Yu-cheng
quoted
Signed-off-by: H.J. Lu <redacted>
Signed-off-by: Yu-cheng Yu <redacted>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <redacted>
Reviewed-by: Kees Cook <redacted>
-Kees
quoted
---
v24:
- Replace CONFIG_X86_CET with CONFIG_X86_IBT to reflect splitting of shadow
stack and ibt.
arch/x86/entry/vdso/Makefile | 4 ++++
1 file changed, 4 insertions(+)