CVE-2024-35802
Assigner: Linux
Published: 2024-05-17T13:23:11.514Z
State: PUBLISHED
descriptions: value: In the Linux kernel, the following vulnerability has been resolved:

x86/sev: Fix position dependent variable references in startup code

The early startup code executes from a 1:1 mapping of memory, which
differs from the mapping that the code was linked and/or relocated to
run at. The latter mapping is not active yet at this point, and so
symbol references that rely on it will fault.

Given that the core kernel is built without -fPIC, symbol references are
typically emitted as absolute, and so any such references occuring in
the early startup code will therefore crash the kernel.

While an attempt was made to work around this for the early SEV/SME
startup code, by forcing RIP-relative addressing for certain global
SEV/SME variables via inline assembly (see snp_cpuid_get_table() for
example), RIP-relative addressing must be pervasively enforced for
SEV/SME global variables when accessed prior to page table fixups.

__startup_64() already handles this issue for select non-SEV/SME global
variables using fixup_pointer(), which adjusts the pointer relative to a
`physaddr` argument. To avoid having to pass around this `physaddr`
argument across all functions needing to apply pointer fixups, introduce
a macro RIP_RELATIVE_REF() which generates a RIP-relative reference to
a given global variable. It is used where necessary to force
RIP-relative accesses to global variables.

For backporting purposes, this patch makes no attempt at cleaning up
other occurrences of this pattern, involving either inline asm or
fixup_pointer(). Those will be addressed later.

  [ bp: Call it "rip_rel_ref" everywhere like other code shortens
    "rIP-relative reference" and make the asm wrapper __always_inline. ]
affected: product: Linux
vendor: Linux
defaultStatus: unaffected
repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
versions: version: 1da177e4c3f4
lessThan: fe272b61506b
status: affected
versionType: git
version: 1da177e4c3f4
lessThan: 0982fd6bf0b8
status: affected
versionType: git
version: 1da177e4c3f4
lessThan: 66fa3fcb474b
status: affected
versionType: git
version: 1da177e4c3f4
lessThan: 954a4a878144
status: affected
versionType: git
version: 1da177e4c3f4
lessThan: 1c811d403afd
status: affected
versionType: git
product: Linux
vendor: Linux
defaultStatus: affected
repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
versions: version: 6.1.84
lessThanOrEqual: 6.1.*
status: unaffected
versionType: custom
version: 6.6.24
lessThanOrEqual: 6.6.*
status: unaffected
versionType: custom
version: 6.7.12
lessThanOrEqual: 6.7.*
status: unaffected
versionType: custom
version: 6.8.3
lessThanOrEqual: 6.8.*
status: unaffected
versionType: custom
version: 6.9
lessThanOrEqual: *
status: unaffected
versionType: original_commit_for_fix
title: x86/sev: Fix position dependent variable references in startup code
x_generator: engine: bippy-d175d3acf727