Skip to content

Commit 7c738cb

Browse files
committed
Merge tag 'x86_entry_for_6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 entry updates from Dave Hansen: "A pair of x86/entry updates. The FRED one adjusts the kernel to the latest spec. The spec change prevents attackers from abusing kernel entry points. The second one came about because of the LASS work[1]. It moves the vsyscall emulation code away from depending on X86_PF_INSTR which is not available on some CPUs. Those CPUs are pretty obscure these days, but this still seems like the right thing to do. It also makes this code consistent with some things that the LASS code is going to do. - Use RIP instead of X86_PF_INSTR for vsyscall emulation - Remove ENDBR64 from FRED entry points" Link: https://lore.kernel.org/lkml/20250620135325.3300848-1-kirill.shutemov@linux.intel.com/ [1] * tag 'x86_entry_for_6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/fred: Remove ENDBR64 from FRED entry points x86/vsyscall: Do not require X86_PF_INSTR to emulate vsyscall
2 parents be786eb + 3da01ff commit 7c738cb

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

arch/x86/entry/entry_64_fred.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
.macro FRED_ENTER
1818
UNWIND_HINT_END_OF_STACK
19-
ENDBR
19+
ANNOTATE_NOENDBR
2020
PUSH_AND_CLEAR_REGS
2121
movq %rsp, %rdi /* %rdi -> pt_regs */
2222
.endm

arch/x86/entry/vsyscall/vsyscall_64.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ bool emulate_vsyscall(unsigned long error_code,
124124
if ((error_code & (X86_PF_WRITE | X86_PF_USER)) != X86_PF_USER)
125125
return false;
126126

127-
if (!(error_code & X86_PF_INSTR)) {
127+
/*
128+
* Assume that faults at regs->ip are because of an
129+
* instruction fetch. Return early and avoid
130+
* emulation for faults during data accesses:
131+
*/
132+
if (address != regs->ip) {
128133
/* Failed vsyscall read */
129134
if (vsyscall_mode == EMULATE)
130135
return false;
@@ -136,13 +141,19 @@ bool emulate_vsyscall(unsigned long error_code,
136141
return false;
137142
}
138143

144+
/*
145+
* X86_PF_INSTR is only set when NX is supported. When
146+
* available, use it to double-check that the emulation code
147+
* is only being used for instruction fetches:
148+
*/
149+
if (cpu_feature_enabled(X86_FEATURE_NX))
150+
WARN_ON_ONCE(!(error_code & X86_PF_INSTR));
151+
139152
/*
140153
* No point in checking CS -- the only way to get here is a user mode
141154
* trap to a high address, which means that we're in 64-bit user code.
142155
*/
143156

144-
WARN_ON_ONCE(address != regs->ip);
145-
146157
if (vsyscall_mode == NONE) {
147158
warn_bad_vsyscall(KERN_INFO, regs,
148159
"vsyscall attempted with vsyscall=none");

0 commit comments

Comments
 (0)