lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231102112850.3448745-1-ubizjak@gmail.com>
Date:   Thu,  2 Nov 2023 12:25:45 +0100
From:   Uros Bizjak <ubizjak@...il.com>
To:     x86@...nel.org, linux-kernel@...r.kernel.org
Cc:     Uros Bizjak <ubizjak@...il.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Peter Zijlstra <peterz@...radead.org>
Subject: [PATCH 0/3] Fix and unify call thunks assembly snippets

Currently INCREMENT_CALL_DEPTH and thunk debug macros explicitly
define %gs: segment register prefix for their percpu variables.
This is not compatible with !CONFIG_SMP, which requires non-prefixed
percpu variables.

Contrary to alternatives, relocations are currently not supported in
call thunk templates. Support for relocations will be needed when
PER_CPU_VAR macro switches to %rip-relative addressing.

Due to unsupported relocations, two variants of INCREMENT_CALL_DEPTH
macro are needed, ASM_ prefixed that allows relocations and
non-prefixed version that allows only absolute addresses.

The following patch series fixes above issues by

a) Moving call thunk template to its own callthunks-tmpl.S assembly file
where PER_CPU_VAR macro from percpu.h can be used to conditionally
use %gs: segment register prefix, depending on CONFIG_SMP.

b) Implementing minimal support for relocations when copying call thunk
template from its storage location to handle %rip-relative addresses.

c) Fixing call thunks debug macros to use PER_CPU_VAR macro from
percpu.h to conditionally use %gs: segment register prefix, depending
on CONFIG_SMP.

d) Unifying ASM_ prefixed assembly macros with their non-prefixed
variants. With support of %rip-relative relocations in place, call
thunk templates allow %rip-relative addressing, so unified assembly
snippet can be used everywhere.

The patch is independent of main percpu series in -tip tree.

Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: Peter Zijlstra <peterz@...radead.org>

Uros Bizjak (3):
  x86/callthunks: Move call thunk template to .S file
  x86/callthunks: Handle %rip-relative relocations in call thunk
    template
  x86/callthunks: Fix and unify call thunks assembly snippets

 arch/x86/include/asm/nospec-branch.h | 23 +++------
 arch/x86/kernel/Makefile             |  2 +-
 arch/x86/kernel/callthunks-tmpl.S    | 11 +++++
 arch/x86/kernel/callthunks.c         | 73 +++++++++++++++++++++-------
 4 files changed, 75 insertions(+), 34 deletions(-)
 create mode 100644 arch/x86/kernel/callthunks-tmpl.S

-- 
2.41.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ