Skip to content

Commit 396c775

Browse files
committed
x86/mm: Add vsyscall address helper
jira LE-1907 cve CVE-2024-26906 Rebuild_History Non-Buildable kernel-4.18.0-553.8.1.el8_10 commit-author Dave Hansen <[email protected]> commit 02e983b We will shortly be using this check in two locations. Put it in a helper before we do so. Let's also insert PAGE_MASK instead of the open-coded ~0xfff. It is easier to read and also more obviously correct considering the implicit type conversion that has to happen when it is not an implicit 'unsigned long'. Cc: [email protected] Cc: Jann Horn <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Andy Lutomirski <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: http://lkml.kernel.org/r/[email protected] (cherry picked from commit 02e983b) Signed-off-by: Jonathan Maple <[email protected]>
1 parent c975944 commit 396c775

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arch/x86/mm/fault.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,15 @@ show_signal_msg(struct pt_regs *regs, unsigned long error_code,
823823
show_opcodes(regs, loglvl);
824824
}
825825

826+
/*
827+
* The (legacy) vsyscall page is the long page in the kernel portion
828+
* of the address space that has user-accessible permissions.
829+
*/
830+
static bool is_vsyscall_vaddr(unsigned long vaddr)
831+
{
832+
return (vaddr & PAGE_MASK) == VSYSCALL_ADDR;
833+
}
834+
826835
static void
827836
__bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
828837
unsigned long address, u32 pkey, int si_code)
@@ -852,7 +861,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
852861
* emulation.
853862
*/
854863
if (unlikely((error_code & X86_PF_INSTR) &&
855-
((address & ~0xfff) == VSYSCALL_ADDR))) {
864+
is_vsyscall_vaddr(address))) {
856865
if (emulate_vsyscall(regs, address))
857866
return;
858867
}

0 commit comments

Comments
 (0)