* [PATCH v6 00/11] vdso: Reject absolute relocations during build
@ 2026-11-23 13:50 Thomas Weißschuh
2026-11-23 13:50 ` [PATCH v6 01/11] vdso: Add the vdsocheck tool Thomas Weißschuh
` (11 more replies)
0 siblings, 12 replies; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:50 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The compiler can emit absolute relocations in vDSO code,
which are invalid in vDSO code.
Detect them at compile-time.
The tool is written in Rust. However this does *not* introduce a Rust
dependency for kernel builds with CONFIG_RUST=n. If no Rust toolchain is
available, the new comprehensive check is skipped automatically.
libc elf.h is missing some of the relocation constants,
so hardcode the magic numbers instead.
Kbuild and Rust folks: This contains custom definitions of hostprog
bindgen and rust library commands.
These are currently only defined inside the subsystem directory.
Let me know if they should go into scripts/Makefile.host.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Changes in v6:
- Drop all UAPI header changes, hardcode relocation numbers instead.
- Add note about Rust *non*-dependency to cover letter.
- Link to v5: https://patch.msgid.link/20260908-vdso-absolute-reloc-v5-0-3a93791af1cf@linutronix.de
Changes in v5:
- Rebase on v7.3-rc1
- s/HOSTRUSTLIB/HOSTRUSTC L/
- Pick up review tags.
- Also handle SPARC.
- Build 'vdsocheck' during the prepare phase.
- Drop now unnecessary riscv LTO preparation patches.
- Link to v4: https://lore.kernel.org/r/20250812-vdso-absolute-reloc-v4-0-61a8b615e5ec@linutronix.de
Changes in v4:
- Replace the inline shell logic with a dedicated build-time tool
- Link to v3: https://lore.kernel.org/r/20250611-vdso-absolute-reloc-v3-0-47897d73784b@linutronix.de
Changes in v3:
- Drop already applied bugfix for arm64
- Disable LTO for the riscv vDSO, as it is incompatible
- Link to v2: https://lore.kernel.org/r/20250430-vdso-absolute-reloc-v2-0-5efcc3bc4b26@linutronix.de
Changes in v2:
- Link to openend (invalid) GCC bug containing more explanations
- Refine commit messages
- Don't fail on commit absolute relocations in debug info
- Link to v1: https://lore.kernel.org/r/20250429-vdso-absolute-reloc-v1-0-987a0afd10b5@linutronix.de
---
Thomas Weißschuh (11):
vdso: Add the vdsocheck tool
x86/vdso: Enable the vdsocheck tool
ARM: vdso: Enable the vdsocheck tool
arm64: vdso: Enable the vdsocheck tool
powerpc/vdso: Enable the vdsocheck tool
riscv: vdso: Enable the vdsocheck tool
LoongArch: vDSO: Enable the vdsocheck tool
s390/vdso: Enable the vdsocheck tool
MIPS: vdso: Enable the vdsocheck tool
sparc: vdso: Enable the vdsocheck tool
vDSO: Automatically enable VDSO_CHECK
Makefile | 19 ++
arch/arm/vdso/Makefile | 4 +-
arch/arm64/kernel/vdso/Makefile | 4 +-
arch/loongarch/vdso/Makefile | 4 +-
arch/mips/vdso/Makefile | 8 +-
arch/powerpc/kernel/vdso/Makefile | 4 +-
arch/riscv/kernel/vdso/Makefile | 4 +-
arch/s390/kernel/vdso/Makefile | 4 +-
arch/sparc/vdso/Makefile | 5 +-
arch/x86/entry/vdso/common/Makefile.include | 2 +-
lib/vdso/Kconfig | 7 +
lib/vdso/Makefile | 2 +
lib/vdso/Makefile.include | 14 +
lib/vdso/check/.gitignore | 3 +
lib/vdso/check/Makefile | 34 ++
lib/vdso/check/elf.rs | 498 ++++++++++++++++++++++++++++
lib/vdso/check/vdsocheck.rs | 299 +++++++++++++++++
17 files changed, 896 insertions(+), 19 deletions(-)
---
base-commit: 0e2fcd5208a4bbe53419a0e4359df3a614135649
change-id: 20250428-vdso-absolute-reloc-a226293c1761
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v6 01/11] vdso: Add the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
@ 2026-11-23 13:50 ` Thomas Weißschuh
2026-11-24 13:52 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 02/11] x86/vdso: Enable " Thomas Weißschuh
` (10 subsequent siblings)
11 siblings, 1 reply; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:50 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
All vDSO code needs to be completely position independent. Symbol
references are marked as hidden so the compiler emits PC-relative
relocations. However there are cases where the compiler may still
emit absolute relocations, as they are valid in regular PIC DSO code.
These would be resolved by the linker and will break at runtime.
This has been observed on arm64, see commit 0c314cda9325 ("arm64: vdso:
Work around invalid absolute relocations from GCC")
Introduce a tool to check for absolute relocations during the build,
as the current inline-shell logic is not expressive enough.
The check is done on the object files as the relocations will not exist
anymore in the final DSO. As there is no extension point for the
compilation of each object file, perform the validation in vdso_check.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Makefile | 19 ++
lib/vdso/Kconfig | 5 +
lib/vdso/Makefile | 2 +
lib/vdso/Makefile.include | 14 ++
lib/vdso/check/.gitignore | 3 +
lib/vdso/check/Makefile | 34 +++
lib/vdso/check/elf.rs | 498 ++++++++++++++++++++++++++++++++++++++++++++
lib/vdso/check/vdsocheck.rs | 154 ++++++++++++++
8 files changed, 729 insertions(+)
diff --git a/Makefile b/Makefile
index f895752d4b05..a3403066c1cf 100644
--- a/Makefile
+++ b/Makefile
@@ -1571,6 +1571,25 @@ vdso_install: export INSTALL_FILES = $(vdso-install-y)
vdso_install:
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
+# ---------------------------------------------------------------------------
+# vDSO check
+
+ifdef CONFIG_RUST_IS_AVAILABLE
+ifdef CONFIG_VDSO_CHECK
+
+# Build the checker early.
+prepare: vdsocheck
+
+# If the architecture builds the vDSO early, make sure to be earlier.
+PHONY += vdso_prepare
+vdso_prepare: vdsocheck
+
+PHONY += vdsocheck
+vdsocheck:
+ $(Q)$(MAKE) $(build)=lib/vdso/check $@
+endif
+endif
+
# ---------------------------------------------------------------------------
# Tools
diff --git a/lib/vdso/Kconfig b/lib/vdso/Kconfig
index 597f5f0f9681..559f5534831e 100644
--- a/lib/vdso/Kconfig
+++ b/lib/vdso/Kconfig
@@ -23,3 +23,8 @@ config VDSO_GETRANDOM
select VDSO_DATASTORE
help
Selected by architectures that support vDSO getrandom().
+
+config VDSO_CHECK
+ bool
+ help
+ Selected for architectures that are supported by the 'vdsocheck' program.
diff --git a/lib/vdso/Makefile b/lib/vdso/Makefile
index ac304def42d6..9932b43d5bac 100644
--- a/lib/vdso/Makefile
+++ b/lib/vdso/Makefile
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_VDSO_DATASTORE) += datastore.o
+
+obj-y += check/
diff --git a/lib/vdso/Makefile.include b/lib/vdso/Makefile.include
index cedbf15f8087..5528e548f02e 100644
--- a/lib/vdso/Makefile.include
+++ b/lib/vdso/Makefile.include
@@ -6,6 +6,12 @@ GENERIC_VDSO_DIR := $(dir $(GENERIC_VDSO_MK_PATH))
c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) := $(addprefix $(GENERIC_VDSO_DIR), gettimeofday.c)
c-getrandom-$(CONFIG_VDSO_GETRANDOM) := $(addprefix $(GENERIC_VDSO_DIR), getrandom.c)
+ifeq ($(CONFIG_RUST_IS_AVAILABLE)$(CONFIG_VDSO_CHECK),yy)
+vdsocheck := lib/vdso/check/vdsocheck
+else
+vdsocheck :=
+endif
+
# This cmd checks that the vdso library does not contain dynamic relocations.
# It has to be called after the linking of the vdso library and requires it
# as a parameter.
@@ -13,6 +19,14 @@ c-getrandom-$(CONFIG_VDSO_GETRANDOM) := $(addprefix $(GENERIC_VDSO_DIR), getrand
# As a workaround for some GNU ld ports which produce unneeded R_*_NONE
# dynamic relocations, ignore R_*_NONE.
quiet_cmd_vdso_check = VDSOCHK $@
+ifneq ($(vdsocheck),)
+ cmd_vdso_check = $(vdsocheck) $(filter %.o, $(real-prereqs)) $@
+else
cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q " R_\w*_"; \
then (echo >&2 "$@: dynamic relocations are not supported"; \
rm -f $@; /bin/false); fi
+endif
+
+# Variant of cmd_ld which does not try to link the vdsocheck tool.
+quiet_cmd_ld_vdso = VDSOLD $@
+ cmd_ld_vdso = $(LD) $(ld_flags) $(filter-out $(vdsocheck), $(real-prereqs)) -o $@
diff --git a/lib/vdso/check/.gitignore b/lib/vdso/check/.gitignore
new file mode 100644
index 000000000000..751be38f11f2
--- /dev/null
+++ b/lib/vdso/check/.gitignore
@@ -0,0 +1,3 @@
+/bindings.rs
+/libbindings.rlib
+/vdsocheck
diff --git a/lib/vdso/check/Makefile b/lib/vdso/check/Makefile
new file mode 100644
index 000000000000..98de42c6c0eb
--- /dev/null
+++ b/lib/vdso/check/Makefile
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+quiet_cmd_host_bindgen = HOSTBINDGEN $@
+ cmd_host_bindgen = $(BINDGEN) $< -o $@ --depfile $(depfile) -- $(HOSTBINDGEN_FLAGS)
+
+quiet_cmd_host_rustlib = HOSTRUSTC L $@
+ cmd_host_rustlib = \
+ $(HOSTRUSTC) $(hostrust_flags) \
+ --emit=dep-info=$(depfile) --emit=link=$@ \
+ --crate-type rlib \
+ --crate-name $(patsubst %.rlib,%,$(notdir $@)) $<
+
+uapi-directory := $(srctree)/tools/include/uapi
+
+# bindings.rs will be generated in the build directory, but rustc can not use
+# source code from both the source and build directory together.
+# Compile the binding code into a library first.
+$(obj)/bindings.rs: HOSTBINDGEN_FLAGS := -I$(uapi-directory)
+$(obj)/bindings.rs: $(uapi-directory)/linux/elf.h FORCE
+ $(call if_changed_dep,host_bindgen)
+
+HOSTRUSTFLAGS_libbindings := -Amissing_docs -Anon-camel-case-types
+$(obj)/libbindings.rlib: $(obj)/bindings.rs FORCE
+ $(call if_changed_dep,host_rustlib)
+
+targets += bindings.rs libbindings.rlib
+
+hostprogs += vdsocheck
+vdsocheck-rust := y
+HOSTRUSTFLAGS_vdsocheck := --extern=bindings=$(obj)/libbindings.rlib
+$(obj)/vdsocheck: $(obj)/libbindings.rlib
+
+PHONY += vdsocheck
+vdsocheck: $(obj)/vdsocheck
diff --git a/lib/vdso/check/elf.rs b/lib/vdso/check/elf.rs
new file mode 100644
index 000000000000..520285d6fd10
--- /dev/null
+++ b/lib/vdso/check/elf.rs
@@ -0,0 +1,498 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#![allow(unreachable_pub)]
+
+use core::fmt;
+use core::iter::Iterator;
+use core::result::Result;
+use core::str;
+
+use ::bindings;
+
+#[derive(Debug, Copy, Clone)]
+enum ByteOrder {
+ LittleEndian,
+ BigEndian,
+}
+
+trait ToCpu {
+ fn to_cpu(self, byteorder: ByteOrder) -> Self;
+}
+
+macro_rules! declare_to_cpu {
+ ($t:ty) => {
+ impl ToCpu for $t {
+ fn to_cpu(self, byteorder: ByteOrder) -> Self {
+ match byteorder {
+ ByteOrder::LittleEndian => Self::from_le(self),
+ ByteOrder::BigEndian => Self::from_be(self),
+ }
+ }
+ }
+ };
+}
+
+declare_to_cpu!(u16);
+declare_to_cpu!(u32);
+declare_to_cpu!(u64);
+
+#[derive(Debug, Copy, Clone)]
+enum Class {
+ Elf32,
+ Elf64,
+}
+
+enum ClassAlternative<T32, T64> {
+ Elf32(T32),
+ Elf64(T64),
+}
+
+#[derive(Debug)]
+pub enum ParseError {
+ InvalidFileMagic([u8; 4]),
+ InvalidFileClass(u32),
+ InvalidFileByteOrder(u32),
+ InvalidSectionSize,
+ MissingStringTable,
+ StrtabIndexOutOfRange,
+ IndexOutOfRange,
+ StrtabInvalidData(str::Utf8Error),
+}
+
+pub type ParseResult<T> = Result<T, ParseError>;
+
+impl fmt::Display for ParseError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ ParseError::InvalidFileMagic(m) => write!(f, "Invalid ELF magic {:?}", m),
+ ParseError::InvalidFileClass(c) => write!(f, "Invalid ELF class {}", c),
+ ParseError::InvalidFileByteOrder(b) => write!(f, "Invalid ELF byteorder {}", b),
+ ParseError::InvalidSectionSize => write!(f, "Invalid ELF section size"),
+ ParseError::MissingStringTable => write!(f, "Missing string table"),
+ ParseError::IndexOutOfRange => write!(f, "Index out of range"),
+ ParseError::StrtabIndexOutOfRange => write!(f, "String table index out of range"),
+ ParseError::StrtabInvalidData(e) => write!(f, "Invalid data in string table: {}", e),
+ }
+ }
+}
+
+fn read_from_bytes<T: Copy>(data: &[u8]) -> ParseResult<T> {
+ if data.len() < core::mem::size_of::<T>() {
+ Err(ParseError::IndexOutOfRange)?
+ }
+ let ptr = data.as_ptr() as *const T;
+ // SAFETY: `T` is `Copy` by the type constraints.
+ // `ptr` is valid as it is derived from the slice `data` above.
+ // `self.data.len()` being large enough is guaranteed by the runtime check above.
+ Ok(unsafe { ptr.read_unaligned() })
+}
+
+fn get_data_subslice(data: &[u8], offset: u64, size: u64) -> ParseResult<&[u8]> {
+ let start: usize = offset.try_into().map_err(|_| ParseError::IndexOutOfRange)?;
+ let size: usize = size.try_into().map_err(|_| ParseError::IndexOutOfRange)?;
+ let end = start.checked_add(size).ok_or(ParseError::IndexOutOfRange)?;
+
+ Ok(&data[start..end])
+}
+
+/// Representation of a complete ELF file.
+#[derive(Debug)]
+pub struct File<'a> {
+ byteorder: ByteOrder,
+ class: Class,
+ pub type_: u16,
+ pub machine: u16,
+ pub data: &'a [u8],
+ section_headers: SectionInfo<'a>,
+ section_names: StrtabSection<'a>,
+}
+
+impl<'a> File<'a> {
+ pub fn new_from_bytes(data: &'a [u8]) -> Result<Self, ParseError> {
+ const ELF_MAGIC: [u8; 4] = [
+ bindings::ELFMAG0 as u8,
+ bindings::ELFMAG1 as u8,
+ bindings::ELFMAG2 as u8,
+ bindings::ELFMAG3 as u8,
+ ];
+ let ehdr: bindings::elf32_hdr = read_from_bytes(data)?;
+
+ let magic = [
+ ehdr.e_ident[bindings::EI_MAG0 as usize],
+ ehdr.e_ident[bindings::EI_MAG1 as usize],
+ ehdr.e_ident[bindings::EI_MAG2 as usize],
+ ehdr.e_ident[bindings::EI_MAG3 as usize],
+ ];
+
+ if magic != ELF_MAGIC {
+ return Err(ParseError::InvalidFileMagic(magic));
+ }
+
+ let class = match ehdr.e_ident[bindings::EI_CLASS as usize] as u32 {
+ bindings::ELFCLASS32 => Class::Elf32,
+ bindings::ELFCLASS64 => Class::Elf64,
+ c => return Err(ParseError::InvalidFileClass(c)),
+ };
+
+ let byteorder = match ehdr.e_ident[bindings::EI_DATA as usize] as u32 {
+ bindings::ELFDATA2LSB => ByteOrder::LittleEndian,
+ bindings::ELFDATA2MSB => ByteOrder::BigEndian,
+ b => return Err(ParseError::InvalidFileByteOrder(b)),
+ };
+
+ let (type_, machine, shnum, shoff, shentsize, shstrndx) = match class {
+ Class::Elf32 => {
+ let ehdr: bindings::elf32_hdr = read_from_bytes(data)?;
+ (
+ ehdr.e_type.to_cpu(byteorder),
+ ehdr.e_machine.to_cpu(byteorder),
+ ehdr.e_shnum.to_cpu(byteorder),
+ ehdr.e_shoff.to_cpu(byteorder).into(),
+ ehdr.e_shentsize.to_cpu(byteorder),
+ ehdr.e_shstrndx.to_cpu(byteorder),
+ )
+ }
+ Class::Elf64 => {
+ let ehdr: bindings::elf64_hdr = read_from_bytes(data)?;
+ (
+ ehdr.e_type.to_cpu(byteorder),
+ ehdr.e_machine.to_cpu(byteorder),
+ ehdr.e_shnum.to_cpu(byteorder),
+ ehdr.e_shoff.to_cpu(byteorder),
+ ehdr.e_shentsize.to_cpu(byteorder),
+ ehdr.e_shstrndx.to_cpu(byteorder),
+ )
+ }
+ };
+
+ let section_headers = SectionInfo {
+ byteorder,
+ class,
+ entsize: shentsize.into(),
+ data: get_data_subslice(data, shoff, u64::from(shnum) * u64::from(shentsize))?,
+ name: "<section headers>",
+ };
+
+ let string_table = SectionHeaderIterator::new(§ion_headers, data)?
+ .nth(shstrndx.into())
+ .ok_or(ParseError::MissingStringTable)??;
+
+ let section_names = StrtabSection(SectionInfo {
+ name: "<section header names>",
+ byteorder,
+ class,
+ data: string_table.data,
+ entsize: string_table.entsize,
+ });
+
+ Ok(File {
+ byteorder,
+ class,
+ type_,
+ machine,
+ section_headers,
+ section_names,
+ data,
+ })
+ }
+
+ pub fn sections(&self) -> ParseResult<SectionIterator<'_>> {
+ Ok(SectionIterator {
+ file: self,
+ section_headers: SectionHeaderIterator::new(&self.section_headers, self.data)?,
+ })
+ }
+}
+
+/// High-level representation of an ELF section.
+#[derive(Clone, Debug)]
+pub struct SectionInfo<'a> {
+ byteorder: ByteOrder,
+ class: Class,
+ pub name: &'a str,
+ entsize: u64,
+ pub data: &'a [u8],
+}
+
+/// Typed high-level iterator over all sections in a `File`.
+#[derive(Debug)]
+pub enum Section<'a> {
+ Null(SectionInfo<'a>),
+ Rel(RelSection<'a>),
+ Rela(RelaSection<'a>),
+ Strtab(StrtabSection<'a>),
+ Unknown(SectionInfo<'a>),
+}
+
+impl<'a> Section<'a> {
+ pub fn info(&'a self) -> &'a SectionInfo<'a> {
+ match self {
+ Section::Null(info) | Section::Unknown(info) => info,
+ Section::Rel(rel) => &rel.0,
+ Section::Rela(rela) => &rela.0,
+ Section::Strtab(strtab) => &strtab.0,
+ }
+ }
+}
+
+pub struct SectionIterator<'a> {
+ file: &'a File<'a>,
+ section_headers: SectionHeaderIterator<'a, 'a>,
+}
+
+impl<'a> Iterator for SectionIterator<'a> {
+ type Item = ParseResult<Section<'a>>;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ self.section_headers.next().map(|header| {
+ let header = header?;
+ let info = SectionInfo {
+ byteorder: self.file.byteorder,
+ class: self.file.class,
+ name: self.file.section_names.entry(header.name)?,
+ entsize: header.entsize,
+ data: header.data,
+ };
+
+ Ok(match header.type_ {
+ bindings::SHT_NULL => Section::Null(info),
+ bindings::SHT_RELA => Section::Rela(RelaSection(info)),
+ bindings::SHT_REL => Section::Rel(RelSection(info)),
+ bindings::SHT_STRTAB => Section::Strtab(StrtabSection(info)),
+ _ => Section::Unknown(info),
+ })
+ })
+ }
+}
+
+/// Iterator over a section of data containing instances of type `T`.
+struct SectionEntityIterator<'a, T: Copy> {
+ data: &'a [u8],
+ byteorder: ByteOrder,
+ _phantom: core::marker::PhantomData<T>,
+}
+
+impl<'a, T: Copy> SectionEntityIterator<'a, T> {
+ const ENTITY_SIZE: usize = core::mem::size_of::<T>();
+
+ fn new(section: &'a SectionInfo<'a>) -> ParseResult<Self> {
+ let data = section.data;
+
+ if section.entsize != Self::ENTITY_SIZE as u64 {
+ return Err(ParseError::InvalidSectionSize);
+ }
+
+ if !data.len().is_multiple_of(Self::ENTITY_SIZE) {
+ return Err(ParseError::InvalidSectionSize);
+ }
+
+ Ok(Self {
+ data,
+ byteorder: section.byteorder,
+ _phantom: core::marker::PhantomData,
+ })
+ }
+}
+
+impl<'a, T: Copy> Iterator for SectionEntityIterator<'a, T> {
+ type Item = T;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ if self.data.len() != 0 {
+ let ptr = self.data.as_ptr() as *const T;
+ // SAFETY: `T` is `Copy` by the type constraints.
+ // `ptr` is valid as it is derived from the slice `data` above.
+ // `self.data.len()` being a multiple of `Self::ENTITY_SIZE` is
+ // guaranteed by `SectionEntityIterator::new`.
+ let entity: T = unsafe { ptr.read_unaligned() };
+ self.data = &self.data[Self::ENTITY_SIZE..];
+ Some(entity)
+ } else {
+ None
+ }
+ }
+}
+
+/// Class-independent representation of an entry in a section header table.
+#[derive(Debug)]
+struct SectionHeader<'a> {
+ name: u32,
+ type_: u32,
+ entsize: u64,
+ data: &'a [u8],
+}
+
+/// Iterator over the section header table.
+struct SectionHeaderIterator<'f: 'a, 'a>(
+ ClassAlternative<
+ SectionEntityIterator<'a, bindings::elf32_shdr>,
+ SectionEntityIterator<'a, bindings::elf64_shdr>,
+ >,
+ &'f [u8],
+);
+
+impl<'f: 'a, 'a> SectionHeaderIterator<'f, 'a> {
+ fn new(section: &'a SectionInfo<'a>, file_data: &'f [u8]) -> ParseResult<Self> {
+ Ok(Self(
+ match section.class {
+ Class::Elf32 => ClassAlternative::Elf32(SectionEntityIterator::new(section)?),
+ Class::Elf64 => ClassAlternative::Elf64(SectionEntityIterator::new(section)?),
+ },
+ file_data,
+ ))
+ }
+}
+
+impl<'f: 'a, 'a> Iterator for SectionHeaderIterator<'f, 'a> {
+ type Item = ParseResult<SectionHeader<'f>>;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ let file_data = self.1;
+
+ match &mut self.0 {
+ ClassAlternative::Elf32(iter) => iter.next().map(|n| {
+ Ok(SectionHeader {
+ name: n.sh_name.to_cpu(iter.byteorder).into(),
+ type_: n.sh_type.to_cpu(iter.byteorder).into(),
+ entsize: n.sh_entsize.to_cpu(iter.byteorder).into(),
+ data: get_data_subslice(
+ file_data,
+ n.sh_offset.to_cpu(iter.byteorder).into(),
+ n.sh_size.to_cpu(iter.byteorder).into(),
+ )?,
+ })
+ }),
+ ClassAlternative::Elf64(iter) => iter.next().map(|n| {
+ Ok(SectionHeader {
+ name: n.sh_name.to_cpu(iter.byteorder).into(),
+ type_: n.sh_type.to_cpu(iter.byteorder).into(),
+ entsize: n.sh_entsize.to_cpu(iter.byteorder).into(),
+ data: get_data_subslice(
+ file_data,
+ n.sh_offset.to_cpu(iter.byteorder).into(),
+ n.sh_size.to_cpu(iter.byteorder).into(),
+ )?,
+ })
+ }),
+ }
+ }
+}
+
+/// High-level interface to a SHT_STRTAB string table.
+#[derive(Debug)]
+pub struct StrtabSection<'a>(SectionInfo<'a>);
+
+impl<'a> StrtabSection<'a> {
+ pub fn entry(&'a self, index: u32) -> ParseResult<&'a str> {
+ let data = self.0.data;
+ let index = index as usize;
+
+ if index >= data.len() {
+ Err(ParseError::StrtabIndexOutOfRange)
+ } else {
+ let len = data[index..]
+ .iter()
+ .position(|b| *b == 0x00)
+ .ok_or(ParseError::StrtabIndexOutOfRange)?;
+ let s = str::from_utf8(&data[index..index + len])
+ .map_err(|e| ParseError::StrtabInvalidData(e))?;
+ Ok(s)
+ }
+ }
+}
+
+/// High-level interface to a SHT_REL relocation table.
+#[derive(Debug)]
+pub struct RelSection<'a>(SectionInfo<'a>);
+
+impl<'a> RelSection<'a> {
+ pub fn entries(&'a self) -> ParseResult<RelSectionIterator<'a>> {
+ RelSectionIterator::new(&self.0)
+ }
+}
+
+#[derive(Debug)]
+pub struct Rel {
+ pub type_: u32,
+}
+
+pub struct RelSectionIterator<'a>(
+ ClassAlternative<
+ SectionEntityIterator<'a, bindings::elf32_rel>,
+ SectionEntityIterator<'a, bindings::elf64_rel>,
+ >,
+);
+
+impl<'a> RelSectionIterator<'a> {
+ fn new(section: &'a SectionInfo<'a>) -> ParseResult<Self> {
+ Ok(Self(match section.class {
+ Class::Elf32 => ClassAlternative::Elf32(SectionEntityIterator::new(section)?),
+ Class::Elf64 => ClassAlternative::Elf64(SectionEntityIterator::new(section)?),
+ }))
+ }
+}
+
+impl<'a> Iterator for RelSectionIterator<'a> {
+ type Item = Rel;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ match &mut self.0 {
+ ClassAlternative::Elf32(iter) => iter.next().map(|n| {
+ let type_ = n.r_info.to_cpu(iter.byteorder) & 0xff;
+ Self::Item { type_ }
+ }),
+ ClassAlternative::Elf64(iter) => iter.next().map(|n| {
+ let type_ = n.r_info.to_cpu(iter.byteorder) as u32;
+ Self::Item { type_ }
+ }),
+ }
+ }
+}
+
+/// High-level interface to a SHT_RELA relocation table.
+#[derive(Debug)]
+pub struct RelaSection<'a>(SectionInfo<'a>);
+
+impl<'a> RelaSection<'a> {
+ pub fn entries(&'a self) -> ParseResult<RelaSectionIterator<'a>> {
+ RelaSectionIterator::new(&self.0)
+ }
+}
+
+#[derive(Debug)]
+pub struct Rela {
+ pub type_: u32,
+}
+
+pub struct RelaSectionIterator<'a>(
+ ClassAlternative<
+ SectionEntityIterator<'a, bindings::elf32_rela>,
+ SectionEntityIterator<'a, bindings::elf64_rela>,
+ >,
+);
+
+impl<'a> RelaSectionIterator<'a> {
+ fn new(section: &'a SectionInfo<'a>) -> ParseResult<Self> {
+ Ok(Self(match section.class {
+ Class::Elf32 => ClassAlternative::Elf32(SectionEntityIterator::new(section)?),
+ Class::Elf64 => ClassAlternative::Elf64(SectionEntityIterator::new(section)?),
+ }))
+ }
+}
+
+impl<'a> Iterator for RelaSectionIterator<'a> {
+ type Item = Rela;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ match &mut self.0 {
+ ClassAlternative::Elf32(iter) => iter.next().map(|n| {
+ let type_ = n.r_info.to_cpu(iter.byteorder) & 0xff;
+ Self::Item { type_ }
+ }),
+ ClassAlternative::Elf64(iter) => iter.next().map(|n| {
+ let type_ = n.r_info.to_cpu(iter.byteorder) as u32;
+ Self::Item { type_ }
+ }),
+ }
+ }
+}
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
new file mode 100644
index 000000000000..f4c0730bc976
--- /dev/null
+++ b/lib/vdso/check/vdsocheck.rs
@@ -0,0 +1,154 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! vDSO build-time validation
+//!
+//! Check that the vDSO library does not contain dynamic relocations.
+
+use std::default::Default;
+use std::fmt;
+use std::fs;
+use std::option::Option;
+use std::process;
+
+use ::bindings;
+
+mod elf;
+
+#[derive(Default)]
+struct AllowedRelocations<'a> {
+ ignored_object_file_sections: &'a [&'a str],
+ in_object_file: &'a [u32],
+}
+
+impl<'a> AllowedRelocations<'a> {
+ fn is_ignored_section(&self, section: &elf::Section<'_>) -> bool {
+ let name = section.info().name;
+
+ if name.starts_with(".rel.debug_") || name.starts_with(".rela.debug_") {
+ true
+ } else {
+ self.ignored_object_file_sections.contains(&name)
+ }
+ }
+}
+
+fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'static>> {
+ match machine as u32 {
+ _ => None,
+ }
+}
+
+#[derive(Debug)]
+enum ValidationError<'a> {
+ ParseError(elf::ParseError),
+ UnsupportedArchitecture(u16),
+ UnrecognizedElfFileType(u32),
+ UnexpectedSection(elf::Section<'a>),
+ InvalidRelocation(elf::Section<'a>, u32),
+}
+
+impl<'a> From<elf::ParseError> for ValidationError<'a> {
+ fn from(parse_error: elf::ParseError) -> Self {
+ Self::ParseError(parse_error)
+ }
+}
+
+impl fmt::Display for ValidationError<'_> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ ValidationError::ParseError(e) => write!(f, "Parsing error: {}", e),
+ ValidationError::UnsupportedArchitecture(n) => {
+ write!(f, "Unsupported ELF architecture {}", n)
+ }
+ ValidationError::UnrecognizedElfFileType(t) => {
+ write!(f, "Unrecognized ELF file type {}", t)
+ }
+ ValidationError::UnexpectedSection(ref s) => {
+ write!(f, "Unexpected section '{}'", s.info().name)
+ }
+ ValidationError::InvalidRelocation(ref s, t) => {
+ write!(f, "Invalid relocation {} in section '{}'", t, s.info().name)
+ }
+ }
+ }
+}
+
+type ValidationResult<'a> = Result<(), ValidationError<'a>>;
+
+fn validate_linked_dso<'a>(file: &'a elf::File<'a>) -> ValidationResult<'a> {
+ for section in file.sections()? {
+ let section = section?;
+
+ /* No relocations are allowed */
+ match section {
+ elf::Section::Rel(_) | elf::Section::Rela(_) => {
+ return Err(ValidationError::UnexpectedSection(section))
+ }
+ _ => {}
+ }
+ }
+
+ Ok(())
+}
+
+fn validate_object_file<'a>(file: &'a elf::File<'a>) -> ValidationResult<'a> {
+ let allowed_relocs = allowed_relocations_for_machine(file.machine)
+ .ok_or(ValidationError::UnsupportedArchitecture(file.machine))?;
+
+ for section in file.sections()? {
+ let section = section?;
+
+ if allowed_relocs.is_ignored_section(§ion) {
+ continue;
+ }
+
+ match section {
+ elf::Section::Rel(ref rel) => {
+ for entry in rel.entries()? {
+ if !allowed_relocs.in_object_file.contains(&entry.type_) {
+ return Err(ValidationError::InvalidRelocation(section, entry.type_));
+ }
+ }
+ }
+ elf::Section::Rela(ref rela) => {
+ for entry in rela.entries()? {
+ if !allowed_relocs.in_object_file.contains(&entry.type_) {
+ return Err(ValidationError::InvalidRelocation(section, entry.type_));
+ }
+ }
+ }
+ _ => {}
+ };
+ }
+
+ Ok(())
+}
+
+fn main() {
+ let mut args = std::env::args_os();
+
+ let program_name = args.next().unwrap_or("vdsocheck".into());
+
+ for path in args {
+ let data = fs::read(&path).unwrap_or_else(|err| {
+ println!("{}: {}: {}", program_name.display(), path.display(), err);
+ process::exit(1);
+ });
+
+ let file = elf::File::new_from_bytes(&data).unwrap_or_else(|err| {
+ println!("{}: {}: {}", program_name.display(), path.display(), err);
+ process::exit(2);
+ });
+
+ let result = match file.type_ as u32 {
+ bindings::ET_DYN => validate_linked_dso(&file),
+ bindings::ET_REL => validate_object_file(&file),
+ t => Err(ValidationError::UnrecognizedElfFileType(t)),
+ };
+
+ result.unwrap_or_else(|err| {
+ println!("{}: {}: {}", program_name.display(), path.display(), err);
+ process::exit(3);
+ });
+ }
+}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 02/11] x86/vdso: Enable the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
2026-11-23 13:50 ` [PATCH v6 01/11] vdso: Add the vdsocheck tool Thomas Weißschuh
@ 2026-11-23 13:50 ` Thomas Weißschuh
2026-11-23 13:50 ` [PATCH v6 03/11] ARM: vdso: " Thomas Weißschuh
` (9 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:50 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/x86/Kconfig | 1 +
arch/x86/entry/vdso/common/Makefile.include | 2 +-
lib/vdso/check/vdsocheck.rs | 14 ++++++++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 58dce0b66179..09d3aa04ee82 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -302,6 +302,7 @@ config X86
select HAVE_UNSTABLE_SCHED_CLOCK
select HAVE_UNWIND_USER_FP if X86_64
select HAVE_USER_RETURN_NOTIFIER
+ select VDSO_CHECK
select VDSO_GETRANDOM if X86_64
select HOTPLUG_PARALLEL if SMP && X86_64
select HOTPLUG_SMT if SMP
diff --git a/arch/x86/entry/vdso/common/Makefile.include b/arch/x86/entry/vdso/common/Makefile.include
index 687b3d89b40d..510d5e79857e 100644
--- a/arch/x86/entry/vdso/common/Makefile.include
+++ b/arch/x86/entry/vdso/common/Makefile.include
@@ -71,7 +71,7 @@ quiet_cmd_vdso = VDSO $@
quiet_cmd_vdso_and_check = VDSO $@
cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
-$(obj)/vdso%.so.dbg: $(obj)/vdso%.lds FORCE
+$(obj)/vdso%.so.dbg: $(obj)/vdso%.lds $(vdsocheck) FORCE
$(call if_changed,vdso_and_check)
$(obj)/%.so: OBJCOPYFLAGS := -S --remove-section __ex_table
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index f4c0730bc976..8cd8c7f3fec8 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -34,6 +34,20 @@ fn is_ignored_section(&self, section: &elf::Section<'_>) -> bool {
fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'static>> {
match machine as u32 {
+ bindings::EM_386 => AllowedRelocations {
+ in_object_file: &[
+ 2, /* R_386_PC32 */
+ 9, /* R_386_GOTOFF */
+ 10, /* R_386_GOTPC */
+ ],
+ ..Default::default()
+ }
+ .into(),
+ bindings::EM_X86_64 => AllowedRelocations {
+ in_object_file: &[2 /* R_X86_64_PC32 */, 4 /* R_X86_64_PLT32 */],
+ ..Default::default()
+ }
+ .into(),
_ => None,
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 03/11] ARM: vdso: Enable the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
2026-11-23 13:50 ` [PATCH v6 01/11] vdso: Add the vdsocheck tool Thomas Weißschuh
2026-11-23 13:50 ` [PATCH v6 02/11] x86/vdso: Enable " Thomas Weißschuh
@ 2026-11-23 13:50 ` Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 04/11] arm64: " Thomas Weißschuh
` (8 subsequent siblings)
11 siblings, 1 reply; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:50 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/arm/mm/Kconfig | 1 +
arch/arm/vdso/Makefile | 4 ++--
lib/vdso/check/vdsocheck.rs | 9 +++++++++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 41d7b495ec45..7f55ed37f464 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -943,6 +943,7 @@ config VDSO
depends on AEABI && MMU && CPU_V7
default y if ARM_ARCH_TIMER
select GENERIC_GETTIMEOFDAY
+ select VDSO_CHECK
help
Place in the process address space an ELF shared object
providing fast implementations of gettimeofday and
diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
index cf8cd39ab804..fd34d0ff018a 100644
--- a/arch/arm/vdso/Makefile
+++ b/arch/arm/vdso/Makefile
@@ -37,7 +37,7 @@ endif
$(obj)/vdso.o : $(obj)/vdso.so
# Link rule for the .so file
-$(obj)/vdso.so.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
+$(obj)/vdso.so.raw: $(obj)/vdso.lds $(obj-vdso) $(vdsocheck) FORCE
$(call if_changed,vdsold_and_vdso_check)
$(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/vdsomunge FORCE
@@ -50,7 +50,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
# Actual build commands
quiet_cmd_vdsold_and_vdso_check = LD $@
- cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
+ cmd_vdsold_and_vdso_check = $(cmd_ld_vdso); $(cmd_vdso_check)
quiet_cmd_vdsomunge = MUNGE $@
cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index 8cd8c7f3fec8..e28ee59a900d 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -48,6 +48,15 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
..Default::default()
}
.into(),
+ bindings::EM_ARM => AllowedRelocations {
+ in_object_file: &[
+ 0, /* R_ARM_NONE */
+ 3, /* R_ARM_REL32 */
+ 42, /* R_ARM_PREL31 */
+ ],
+ ..Default::default()
+ }
+ .into(),
_ => None,
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 04/11] arm64: vdso: Enable the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
` (2 preceding siblings ...)
2026-11-23 13:50 ` [PATCH v6 03/11] ARM: vdso: " Thomas Weißschuh
@ 2026-11-23 13:50 ` Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 05/11] powerpc/vdso: " Thomas Weißschuh
` (7 subsequent siblings)
11 siblings, 1 reply; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:50 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
The compat vDSO will be handled by the existing 32-bit ARM configuration.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/arm64/Kconfig | 1 +
arch/arm64/kernel/vdso/Makefile | 4 ++--
lib/vdso/check/vdsocheck.rs | 12 ++++++++++++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1075bc661833..df22b4ed5e29 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -258,6 +258,7 @@ config ARM64
select TRACE_IRQFLAGS_NMI_SUPPORT
select HAVE_SOFTIRQ_ON_OWN_STACK
select USER_STACKTRACE_SUPPORT
+ select VDSO_CHECK
select VDSO_GETRANDOM
select VMAP_STACK
help
diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
index f6619e1cb2ce..5d8c34c7be51 100644
--- a/arch/arm64/kernel/vdso/Makefile
+++ b/arch/arm64/kernel/vdso/Makefile
@@ -61,7 +61,7 @@ targets += vdso.lds
CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
# Link rule for the .so file, .lds has to be first
-$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
+$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) $(vdsocheck) FORCE
$(call if_changed,vdsold_and_vdso_check)
# Strip rule for the .so file
@@ -79,4 +79,4 @@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
# Actual build commands
quiet_cmd_vdsold_and_vdso_check = LD $@
- cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
+ cmd_vdsold_and_vdso_check = $(cmd_ld_vdso); $(cmd_vdso_check)
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index e28ee59a900d..0d5ceaca34d7 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -57,6 +57,18 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
..Default::default()
}
.into(),
+ bindings::EM_AARCH64 => AllowedRelocations {
+ in_object_file: &[
+ 260, /* R_AARCH64_PREL64 */
+ 261, /* R_AARCH64_PREL32 */
+ 262, /* R_AARCH64_PREL16 */
+ 273, /* R_AARCH64_LD_PREL_LO19 */
+ 274, /* R_AARCH64_ADR_PREL_LO21 */
+ 283, /* R_AARCH64_CALL26 */
+ ],
+ ..Default::default()
+ }
+ .into(),
_ => None,
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 05/11] powerpc/vdso: Enable the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
` (3 preceding siblings ...)
2026-11-23 13:50 ` [PATCH v6 04/11] arm64: " Thomas Weißschuh
@ 2026-11-23 13:50 ` Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 06/11] riscv: vdso: " Thomas Weißschuh
` (6 subsequent siblings)
11 siblings, 1 reply; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:50 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/vdso/Makefile | 4 ++--
lib/vdso/check/vdsocheck.rs | 27 +++++++++++++++++++++++++++
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c3b6cd655606..1c4a75c3a830 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -327,6 +327,7 @@ config PPC
select SYSCTL_EXCEPTION_TRACE
select THREAD_INFO_IN_TASK
select TRACE_IRQFLAGS_SUPPORT
+ select VDSO_CHECK
select VDSO_DATASTORE
select VDSO_GETRANDOM
#
diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
index 0d1a49529885..b2e399e10273 100644
--- a/arch/powerpc/kernel/vdso/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -82,9 +82,9 @@ targets += vdso64.lds
CPPFLAGS_vdso64.lds += -P -C
# link rule for the .so file, .lds has to be first
-$(obj)/vdso32.so.dbg: $(obj)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday-32.o $(obj)/vgetrandom-32.o $(obj)/crtsavres-32.o FORCE
+$(obj)/vdso32.so.dbg: $(obj)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday-32.o $(obj)/vgetrandom-32.o $(obj)/crtsavres-32.o $(vdsocheck) FORCE
$(call if_changed,vdso32ld_and_check)
-$(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday-64.o $(obj)/vgetrandom-64.o FORCE
+$(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday-64.o $(obj)/vgetrandom-64.o $(vdsocheck) FORCE
$(call if_changed,vdso64ld_and_check)
# assembly rules for the .S files
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index 0d5ceaca34d7..da58ff220eab 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -69,6 +69,33 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
..Default::default()
}
.into(),
+ bindings::EM_PPC => AllowedRelocations {
+ in_object_file: &[
+ 10, /* R_PPC_REL24 */
+ 11, /* R_PPC_REL14 */
+ 26, /* R_PPC_REL32 */
+ 249, /* R_PPC_REL16 */
+ 250, /* R_PPC_REL16_LO */
+ 251, /* R_PPC_REL16_HI */
+ 252, /* R_PPC_REL16_HA */
+ ],
+ ..Default::default()
+ }
+ .into(),
+ bindings::EM_PPC64 => AllowedRelocations {
+ in_object_file: &[
+ 10, /* R_PPC64_REL24 */
+ 11, /* R_PPC64_REL14 */
+ 26, /* R_PPC64_REL32 */
+ 44, /* R_PPC64_REL64 */
+ 249, /* R_PPC64_REL16 */
+ 250, /* R_PPC64_REL16_LO */
+ 251, /* R_PPC64_REL16_HI */
+ 252, /* R_PPC64_REL16_HA */
+ ],
+ ..Default::default()
+ }
+ .into(),
_ => None,
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 06/11] riscv: vdso: Enable the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
` (4 preceding siblings ...)
2026-11-23 13:50 ` [PATCH v6 05/11] powerpc/vdso: " Thomas Weißschuh
@ 2026-11-23 13:50 ` Thomas Weißschuh
2026-11-23 13:50 ` [PATCH v6 07/11] LoongArch: vDSO: " Thomas Weißschuh
` (5 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:50 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/riscv/Kconfig | 1 +
arch/riscv/kernel/vdso/Makefile | 4 ++--
lib/vdso/check/vdsocheck.rs | 26 ++++++++++++++++++++++++++
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index e7891a2a89da..2a0f5fbcd7e3 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -226,6 +226,7 @@ config RISCV
select THREAD_INFO_IN_TASK
select TRACE_IRQFLAGS_SUPPORT
select UACCESS_MEMCPY if !MMU
+ select VDSO_CHECK if MMU
select VDSO_DATASTORE if MMU
select VDSO_GETRANDOM if MMU && 64BIT
select USER_STACKTRACE_SUPPORT
diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
index c023046a3fd7..b15039d0309e 100644
--- a/arch/riscv/kernel/vdso/Makefile
+++ b/arch/riscv/kernel/vdso/Makefile
@@ -75,7 +75,7 @@ endif
$(obj)/$(vdso_o): $(obj)/$(vdso_so)
# link rule for the .so file, .lds has to be first
-$(obj)/$(vdso_so_dbg): $(obj)/$(vdso_lds) $(obj-vdso) FORCE
+$(obj)/$(vdso_so_dbg): $(obj)/$(vdso_lds) $(obj-vdso) $(vdsocheck) FORCE
$(call if_changed,vdsold_and_check)
LDFLAGS_$(vdso_so_dbg) = -shared -soname=linux-vdso.so.1 \
--build-id=sha1 --eh-frame-hdr
@@ -97,7 +97,7 @@ include/generated/$(vdso_offsets): $(obj)/$(vdso_so_dbg) FORCE
# The DSO images are built using a special linker script
# Make sure only to export the intended __vdso_xxx symbol offsets.
quiet_cmd_vdsold_and_check = VDSOLD $@
- cmd_vdsold_and_check = $(LD) $(CFI_FULL) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
+ cmd_vdsold_and_check = $(LD) $(CFI_FULL) $(ld_flags) -T $(filter-out FORCE $(vdsocheck),$^) -o $@.tmp && \
$(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
rm $@.tmp && \
$(cmd_vdso_check)
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index da58ff220eab..37455d326110 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -96,6 +96,32 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
..Default::default()
}
.into(),
+ bindings::EM_RISCV => AllowedRelocations {
+ in_object_file: &[
+ 16, /* R_RISCV_BRANCH */
+ 17, /* R_RISCV_JAL */
+ 18, /* R_RISCV_CALL */
+ 19, /* R_RISCV_CALL_PLT */
+ 23, /* R_RISCV_PCREL_HI20 */
+ 24, /* R_RISCV_PCREL_LO12_I */
+ 25, /* R_RISCV_PCREL_LO12_S */
+ 33, /* R_RISCV_ADD8 */
+ 34, /* R_RISCV_ADD16 */
+ 35, /* R_RISCV_ADD32 */
+ 36, /* R_RISCV_ADD64 */
+ 37, /* R_RISCV_SUB8 */
+ 38, /* R_RISCV_SUB16 */
+ 39, /* R_RISCV_SUB32 */
+ 40, /* R_RISCV_SUB64 */
+ 43, /* R_RISCV_ALIGN */
+ 44, /* R_RISCV_RVC_BRANCH */
+ 45, /* R_RISCV_RVC_JUMP */
+ 51, /* R_RISCV_RELAX */
+ 57, /* R_RISCV_32_PCREL */
+ ],
+ ..Default::default()
+ }
+ .into(),
_ => None,
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 07/11] LoongArch: vDSO: Enable the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
` (5 preceding siblings ...)
2026-11-23 13:50 ` [PATCH v6 06/11] riscv: vdso: " Thomas Weißschuh
@ 2026-11-23 13:50 ` Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 08/11] s390/vdso: " Thomas Weißschuh
` (4 subsequent siblings)
11 siblings, 1 reply; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:50 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/loongarch/Kconfig | 1 +
arch/loongarch/vdso/Makefile | 4 ++--
lib/vdso/check/vdsocheck.rs | 26 ++++++++++++++++++++++++++
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index b5ed4881d3c0..ad4cafeddbb8 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -211,6 +211,7 @@ config LOONGARCH
select TRACE_IRQFLAGS_SUPPORT
select USE_PERCPU_NUMA_NODE_ID
select USER_STACKTRACE_SUPPORT
+ select VDSO_CHECK
select VDSO_DATASTORE
select VDSO_GETRANDOM
select ZONE_DMA32 if 64BIT
diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
index 0b84892d084b..ad54383b1908 100644
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -51,7 +51,7 @@ ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
#
quiet_cmd_vdsold_and_vdso_check = LD $@
- cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
+ cmd_vdsold_and_vdso_check = $(cmd_ld_vdso); $(cmd_vdso_check)
quiet_cmd_vdsoas_o_S = AS $@
cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
@@ -80,7 +80,7 @@ $(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
-$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
+$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) $(vdsocheck) FORCE
$(call if_changed,vdsold_and_vdso_check)
$(obj)/vdso.so: OBJCOPYFLAGS := -S
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index 37455d326110..7952ad6ba72b 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -122,6 +122,32 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
..Default::default()
}
.into(),
+ bindings::EM_LOONGARCH => AllowedRelocations {
+ in_object_file: &[
+ 47, /* R_LARCH_ADD8 */
+ 48, /* R_LARCH_ADD16 */
+ 49, /* R_LARCH_ADD24 */
+ 50, /* R_LARCH_ADD32 */
+ 51, /* R_LARCH_ADD64 */
+ 52, /* R_LARCH_SUB8 */
+ 53, /* R_LARCH_SUB16 */
+ 54, /* R_LARCH_SUB24 */
+ 55, /* R_LARCH_SUB32 */
+ 56, /* R_LARCH_SUB64 */
+ 64, /* R_LARCH_B16 */
+ 65, /* R_LARCH_B21 */
+ 66, /* R_LARCH_B26 */
+ 71, /* R_LARCH_PCALA_HI20 */
+ 72, /* R_LARCH_PCALA_LO12 */
+ 73, /* R_LARCH_PCALA64_LO20 */
+ 74, /* R_LARCH_PCALA64_HI12 */
+ 99, /* R_LARCH_32_PCREL */
+ 128, /* R_LARCH_PCADD_HI20 */
+ 128, /* R_LARCH_PCADD_LO12 */
+ ],
+ ..Default::default()
+ }
+ .into(),
_ => None,
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 08/11] s390/vdso: Enable the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
` (6 preceding siblings ...)
2026-11-23 13:50 ` [PATCH v6 07/11] LoongArch: vDSO: " Thomas Weißschuh
@ 2026-11-23 13:50 ` Thomas Weißschuh
2026-11-23 13:51 ` [PATCH v6 09/11] MIPS: vdso: " Thomas Weißschuh
` (3 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:50 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/s390/Kconfig | 1 +
arch/s390/kernel/vdso/Makefile | 4 ++--
lib/vdso/check/vdsocheck.rs | 9 +++++++++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 7138d923d86f..71a614832886 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -289,6 +289,7 @@ config S390
select TRACE_IRQFLAGS_SUPPORT
select TTY
select USER_STACKTRACE_SUPPORT
+ select VDSO_CHECK
select VDSO_GETRANDOM
select VIRT_CPU_ACCOUNTING
select VMAP_STACK
diff --git a/arch/s390/kernel/vdso/Makefile b/arch/s390/kernel/vdso/Makefile
index 54bcf2984ca1..6bc2b7bffd89 100644
--- a/arch/s390/kernel/vdso/Makefile
+++ b/arch/s390/kernel/vdso/Makefile
@@ -45,10 +45,10 @@ CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
$(obj)/vdso_wrapper.o : $(obj)/vdso.so
quiet_cmd_vdso_and_check = VDSO $@
- cmd_vdso_and_check = $(cmd_ld); $(cmd_vdso_check)
+ cmd_vdso_and_check = $(cmd_ld_vdso); $(cmd_vdso_check)
# link rule for the .so file, .lds has to be first
-$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) $(obj-cvdso) FORCE
+$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) $(obj-cvdso) $(vdsocheck) FORCE
$(call if_changed,vdso_and_check)
# strip rule for the .so file
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index 7952ad6ba72b..1ef3f240f886 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -148,6 +148,15 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
..Default::default()
}
.into(),
+ bindings::EM_S390 => AllowedRelocations {
+ in_object_file: &[
+ 5, /* R_390_PC32 */
+ 19, /* R_390_PC32DBL */
+ 20, /* R_390_PLT32DBL */
+ ],
+ ..Default::default()
+ }
+ .into(),
_ => None,
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 09/11] MIPS: vdso: Enable the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
` (7 preceding siblings ...)
2026-11-23 13:50 ` [PATCH v6 08/11] s390/vdso: " Thomas Weißschuh
@ 2026-11-23 13:51 ` Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:51 ` [PATCH v6 10/11] sparc: " Thomas Weißschuh
` (2 subsequent siblings)
11 siblings, 1 reply; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:51 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/mips/Kconfig | 1 +
arch/mips/vdso/Makefile | 8 ++++----
lib/vdso/check/vdsocheck.rs | 15 +++++++++++++++
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ed17c9b1624c..31c247c2faeb 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -106,6 +106,7 @@ config MIPS
select TRACE_IRQFLAGS_SUPPORT
select ARCH_HAS_ELFCORE_COMPAT
select HAVE_ARCH_KCSAN if 64BIT
+ select VDSO_CHECK
config MIPS_FIXUP_BIGPHYS_ADDR
bool
diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
index 00d3ba2c482a..63060057cd21 100644
--- a/arch/mips/vdso/Makefile
+++ b/arch/mips/vdso/Makefile
@@ -66,7 +66,7 @@ quiet_cmd_vdso_mips_check = VDSOCHK $@
#
quiet_cmd_vdsold_and_vdso_check = LD $@
- cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check); $(cmd_vdso_mips_check)
+ cmd_vdsold_and_vdso_check = $(cmd_ld_vdso); $(cmd_vdso_check); $(cmd_vdso_mips_check)
quiet_cmd_vdsoas_o_S = AS $@
cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
@@ -103,7 +103,7 @@ $(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
-$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
+$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) $(vdsocheck) FORCE
$(call if_changed,vdsold_and_vdso_check)
$(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \
@@ -141,7 +141,7 @@ $(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32
$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
$(call if_changed_dep,cpp_lds_S)
-$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE
+$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) $(vdsocheck) FORCE
$(call if_changed,vdsold_and_vdso_check)
$(obj)/vdso-o32-image.c: VDSO_NAME := o32
@@ -181,7 +181,7 @@ $(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32
$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE
$(call if_changed_dep,cpp_lds_S)
-$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE
+$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) $(vdsocheck) FORCE
$(call if_changed,vdsold_and_vdso_check)
$(obj)/vdso-n32-image.c: VDSO_NAME := n32
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index 1ef3f240f886..120d8fa551e6 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -157,6 +157,21 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
..Default::default()
}
.into(),
+ bindings::EM_MIPS => AllowedRelocations {
+ ignored_object_file_sections: &[".rel.pdr", ".rela.pdr"],
+ in_object_file: &[
+ 10, /* R_MIPS_PC16 */
+ 60, /* R_MIPS_PC21_S2 */
+ 61, /* R_MIPS_PC26_S2 */
+ 62, /* R_MIPS_PC18_S3 */
+ 63, /* R_MIPS_PC19_S2 */
+ 64, /* R_MIPS_PCHI16 */
+ 65, /* R_MIPS_PCLO16 */
+ 248, /* R_MIPS_PC32 */
+ ],
+ ..Default::default()
+ }
+ .into(),
_ => None,
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 10/11] sparc: vdso: Enable the vdsocheck tool
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
` (8 preceding siblings ...)
2026-11-23 13:51 ` [PATCH v6 09/11] MIPS: vdso: " Thomas Weißschuh
@ 2026-11-23 13:51 ` Thomas Weißschuh
2026-11-23 13:51 ` [PATCH v6 11/11] vDSO: Automatically enable VDSO_CHECK Thomas Weißschuh
2026-11-24 13:53 ` [PATCH v6 00/11] vdso: Reject absolute relocations during build sashiko-bot
11 siblings, 0 replies; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:51 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/sparc/Kconfig | 1 +
arch/sparc/vdso/Makefile | 5 +++--
lib/vdso/check/vdsocheck.rs | 7 +++++++
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 742ffff8c37f..90df77235184 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -114,6 +114,7 @@ config SPARC64
select ARCH_SUPPORTS_SCHED_SMT if SMP
select ARCH_SUPPORTS_SCHED_MC if SMP
select ARCH_HAS_LAZY_MMU_MODE
+ select VDSO_CHECK
select GENERIC_GETTIMEOFDAY
config ARCH_PROC_KCORE_TEXT
diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile
index 83fb2aca59cb..8bb235c3a618 100644
--- a/arch/sparc/vdso/Makefile
+++ b/arch/sparc/vdso/Makefile
@@ -28,7 +28,7 @@ CPPFLAGS_vdso.lds += -P -C
VDSO_LDFLAGS_vdso.lds = -m elf64_sparc -soname linux-vdso.so.1 \
-z max-page-size=8192
-$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
+$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) $(vdsocheck) FORCE
$(call if_changed,vdso)
HOST_EXTRACFLAGS += -I$(srctree)/tools/include
@@ -99,7 +99,8 @@ $(obj)/vdso32.so.dbg: CHECKFLAGS = $(CHECKFLAGS_32)
$(obj)/vdso32.so.dbg: FORCE \
$(obj)/vdso32/vdso32.lds \
$(obj)/vdso32/vclock_gettime.o \
- $(obj)/vdso32/vdso-note.o
+ $(obj)/vdso32/vdso-note.o \
+ $(vdsocheck)
$(call if_changed,vdso)
#
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index 120d8fa551e6..245d8af9f704 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -172,6 +172,13 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
..Default::default()
}
.into(),
+ bindings::EM_SPARC | bindings::EM_SPARC32PLUS | bindings::EM_SPARCV9 => {
+ AllowedRelocations {
+ in_object_file: &[6 /* R_SPARC_DISP32 */],
+ ..Default::default()
+ }
+ .into()
+ }
_ => None,
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 11/11] vDSO: Automatically enable VDSO_CHECK
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
` (9 preceding siblings ...)
2026-11-23 13:51 ` [PATCH v6 10/11] sparc: " Thomas Weißschuh
@ 2026-11-23 13:51 ` Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-24 13:53 ` [PATCH v6 00/11] vdso: Reject absolute relocations during build sashiko-bot
11 siblings, 1 reply; 20+ messages in thread
From: Thomas Weißschuh @ 2026-11-23 13:51 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Lutomirski, Vincenzo Frascino, Kees Cook, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Richard Weinberger, Anton Ivanov, Johannes Berg, Russell King,
Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-riscv, linux-kernel, llvm, linux-mm, linux-um,
linux-arm-kernel, linuxppc-dev, loongarch, linux-s390, linux-mips,
rust-for-linux, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra, Thomas Weißschuh
All architectures using the generic vDSO library should enable
VDSO_CHECK. Now that this is the case, enable VDSO_CHECK automatically.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/arm/mm/Kconfig | 1 -
arch/arm64/Kconfig | 1 -
arch/loongarch/Kconfig | 1 -
arch/mips/Kconfig | 1 -
arch/powerpc/Kconfig | 1 -
arch/riscv/Kconfig | 1 -
arch/s390/Kconfig | 1 -
arch/sparc/Kconfig | 1 -
arch/x86/Kconfig | 1 -
lib/vdso/Kconfig | 2 ++
10 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 7f55ed37f464..41d7b495ec45 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -943,7 +943,6 @@ config VDSO
depends on AEABI && MMU && CPU_V7
default y if ARM_ARCH_TIMER
select GENERIC_GETTIMEOFDAY
- select VDSO_CHECK
help
Place in the process address space an ELF shared object
providing fast implementations of gettimeofday and
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index df22b4ed5e29..1075bc661833 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -258,7 +258,6 @@ config ARM64
select TRACE_IRQFLAGS_NMI_SUPPORT
select HAVE_SOFTIRQ_ON_OWN_STACK
select USER_STACKTRACE_SUPPORT
- select VDSO_CHECK
select VDSO_GETRANDOM
select VMAP_STACK
help
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index ad4cafeddbb8..b5ed4881d3c0 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -211,7 +211,6 @@ config LOONGARCH
select TRACE_IRQFLAGS_SUPPORT
select USE_PERCPU_NUMA_NODE_ID
select USER_STACKTRACE_SUPPORT
- select VDSO_CHECK
select VDSO_DATASTORE
select VDSO_GETRANDOM
select ZONE_DMA32 if 64BIT
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 31c247c2faeb..ed17c9b1624c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -106,7 +106,6 @@ config MIPS
select TRACE_IRQFLAGS_SUPPORT
select ARCH_HAS_ELFCORE_COMPAT
select HAVE_ARCH_KCSAN if 64BIT
- select VDSO_CHECK
config MIPS_FIXUP_BIGPHYS_ADDR
bool
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 1c4a75c3a830..c3b6cd655606 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -327,7 +327,6 @@ config PPC
select SYSCTL_EXCEPTION_TRACE
select THREAD_INFO_IN_TASK
select TRACE_IRQFLAGS_SUPPORT
- select VDSO_CHECK
select VDSO_DATASTORE
select VDSO_GETRANDOM
#
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 2a0f5fbcd7e3..e7891a2a89da 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -226,7 +226,6 @@ config RISCV
select THREAD_INFO_IN_TASK
select TRACE_IRQFLAGS_SUPPORT
select UACCESS_MEMCPY if !MMU
- select VDSO_CHECK if MMU
select VDSO_DATASTORE if MMU
select VDSO_GETRANDOM if MMU && 64BIT
select USER_STACKTRACE_SUPPORT
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 71a614832886..7138d923d86f 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -289,7 +289,6 @@ config S390
select TRACE_IRQFLAGS_SUPPORT
select TTY
select USER_STACKTRACE_SUPPORT
- select VDSO_CHECK
select VDSO_GETRANDOM
select VIRT_CPU_ACCOUNTING
select VMAP_STACK
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 90df77235184..742ffff8c37f 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -114,7 +114,6 @@ config SPARC64
select ARCH_SUPPORTS_SCHED_SMT if SMP
select ARCH_SUPPORTS_SCHED_MC if SMP
select ARCH_HAS_LAZY_MMU_MODE
- select VDSO_CHECK
select GENERIC_GETTIMEOFDAY
config ARCH_PROC_KCORE_TEXT
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 09d3aa04ee82..58dce0b66179 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -302,7 +302,6 @@ config X86
select HAVE_UNSTABLE_SCHED_CLOCK
select HAVE_UNWIND_USER_FP if X86_64
select HAVE_USER_RETURN_NOTIFIER
- select VDSO_CHECK
select VDSO_GETRANDOM if X86_64
select HOTPLUG_PARALLEL if SMP && X86_64
select HOTPLUG_SMT if SMP
diff --git a/lib/vdso/Kconfig b/lib/vdso/Kconfig
index 559f5534831e..741de1abe923 100644
--- a/lib/vdso/Kconfig
+++ b/lib/vdso/Kconfig
@@ -6,6 +6,7 @@ config VDSO_DATASTORE
config GENERIC_GETTIMEOFDAY
bool
select VDSO_DATASTORE
+ select VDSO_CHECK
help
This is a generic implementation of gettimeofday vdso.
Each architecture that enables this feature has to
@@ -21,6 +22,7 @@ config GENERIC_VDSO_OVERFLOW_PROTECT
config VDSO_GETRANDOM
bool
select VDSO_DATASTORE
+ select VDSO_CHECK
help
Selected by architectures that support vDSO getrandom().
--
2.56.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v6 01/11] vdso: Add the vdsocheck tool
2026-11-23 13:50 ` [PATCH v6 01/11] vdso: Add the vdsocheck tool Thomas Weißschuh
@ 2026-11-24 13:52 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-11-24 13:52 UTC (permalink / raw)
To: Thomas Weißschuh, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Lutomirski, Vincenzo Frascino,
Kees Cook, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Richard Weinberger, Anton Ivanov, Johannes Berg,
Russell King, Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-mm, linux-s390, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] vdso: vdsocheck uses Rust 1.87 APIs breaking 1.85.0 minimum
version
- [Medium] vdso: unchecked slice in get_data_subslice() and SHT_NOBITS
slicing
- [Medium] vdso: missing include/uapi in HOSTBINDGEN_FLAGS and + on
host_rustlib
- [Medium] vdso: validate_linked_dso() rejects SHT_REL/SHT_RELA with
R_*_NONE
- [Low] vdso: missing scripts_basic prerequisite on vdsocheck Makefile
target
- [Low] vdso: vdsocheck main() prints errors to stdout instead of stderr
--
commit ba87ba62d5b7688443f8778322978989d53ab4f8
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
vdso: Add the vdsocheck tool
This commit adds a Rust host build tool, vdsocheck, along with Kbuild
rules to validate that vDSO object files and the linked vDSO shared object
do not contain invalid relocations.
[Severity: Low]
In Makefile (at the vdsocheck target, lines 1575-1577), does the vdsocheck
target need a dependency on scripts_basic?
Building bindings.rs, libbindings.rlib, and vdsocheck in
lib/vdso/check/Makefile uses if_changed_dep, which runs
scripts/basic/fixdep. In a parallel build from a clean tree (or via make
vdsocheck), vdsocheck can run before scripts_basic finishes and fail with a
missing fixdep binary.
[Severity: Medium]
In lib/vdso/check/Makefile (lines 18-24), can building bindings.rs fail
when the host lacks kernel UAPI headers or has an older
/usr/include/linux/elf-em.h?
tools/include/uapi/linux/elf.h includes <linux/types.h> (which includes
<asm-generic/int-ll64.h>) and <linux/elf-em.h>, which reside in
$(srctree)/include/uapi rather than $(srctree)/tools/include/uapi. Passing
only -I$(srctree)/tools/include/uapi in HOSTBINDGEN_FLAGS causes bindgen to
fall back to the host's /usr/include.
Also on line 24, the $(call if_changed_dep,host_rustlib) rule for
$(obj)/libbindings.rlib is missing a leading '+' prefix, so GNU Make closes
the jobserver file descriptors and rustc emits a jobserver warning that
fails the build under CONFIG_WERROR=y.
[Severity: Medium]
In lib/vdso/check/elf.rs, inside get_data_subslice() (lines 87-96) and
SectionHeaderIterator::next() (lines 355-374), can get_data_subslice()
panic on out-of-bounds slices or on SHT_NOBITS sections?
get_data_subslice() checks start.checked_add(size) for integer overflow,
but then directly indexes &data[start..end] without checking end <=
data.len(), panicking instead of returning Err(ParseError::IndexOutOfRange)
when a section or header extends past the end of the file. In addition,
SectionHeaderIterator::next() unconditionally calls get_data_subslice() for
every section header using sh_offset and sh_size. Because SHT_NOBITS
sections (such as .bss) occupy no space in the file, their sh_offset +
sh_size can legitimately exceed file_data.len() and trigger a panic. Using
data.get(start..end).ok_or(ParseError::IndexOutOfRange) and passing a size
of 0 when sh_type == bindings::SHT_NOBITS would avoid this.
[Severity: Medium]
In lib/vdso/check/elf.rs (SectionEntityIterator::new(), line 285) and
lib/vdso/check/vdsocheck.rs (main(), lines 134, 139, and 150), does this
fail to build on Rust 1.85.x and 1.86.x?
The minimum supported Rust version in Documentation/process/changes.rst is
1.85.0, and KBUILD_HOSTRUSTFLAGS passes -Zallow-features= to disallow
unstable features in host tools. However, usize::is_multiple_of() in
SectionEntityIterator::new() and OsStr::display() on the OsString values in
main() were only stabilized in Rust 1.87.0, causing E0658 compilation
errors on older supported compilers.
[Severity: Medium]
In lib/vdso/check/vdsocheck.rs (validate_linked_dso(), lines 78-92), does
validate_linked_dso() reject linked vDSOs that contain only R_*_NONE
relocations?
As noted in the comment above cmd_vdso_check in lib/vdso/Makefile.include
and in commit aff69273af61 ("vdso: Improve cmd_vdso_check to check all
dynamic relocations"), some GNU ld ports emit trailing R_*_NONE (type 0)
dynamic relocations in .rel.dyn or .rela.dyn, which the readelf fallback
explicitly filters out. validate_linked_dso() rejects any SHT_REL or
SHT_RELA section unconditionally without checking whether its entries are
all R_*_NONE.
[Severity: Low]
In lib/vdso/check/vdsocheck.rs (main(), lines 134, 139, and 150), should
these error messages use eprintln!() instead of println!()?
Silent kernel builds (make -s) redirect stdout of build commands to
/dev/null, so printing fatal errors to stdout hides the failure diagnostic.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-vdso-absolute-reloc-v6-0-161e218dd217@linutronix.de?part=1
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 03/11] ARM: vdso: Enable the vdsocheck tool
2026-11-23 13:50 ` [PATCH v6 03/11] ARM: vdso: " Thomas Weißschuh
@ 2026-11-24 13:53 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-11-24 13:53 UTC (permalink / raw)
To: Thomas Weißschuh, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Lutomirski, Vincenzo Frascino,
Kees Cook, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Richard Weinberger, Anton Ivanov, Johannes Berg,
Russell King, Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-mm, linux-s390, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] ARM: vdso: incomplete EM_ARM allowlist in
allowed_relocations_for_machine()
--
commit cb0c70494d3f8ce1bc0651e74508d837c36a4e17
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
ARM: vdso: Enable the vdsocheck tool
This commit enables the vdsocheck build-time validation tool for 32-bit ARM
vDSO builds and defines the allowed ELF object relocations for EM_ARM.
> diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
> index 8cd8c7f3fec85..e28ee59a900dd 100644
> --- a/lib/vdso/check/vdsocheck.rs
> +++ b/lib/vdso/check/vdsocheck.rs
> @@ -48,6 +48,15 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
> ..Default::default()
> }
> .into(),
> + bindings::EM_ARM => AllowedRelocations {
> + in_object_file: &[
> + 0, /* R_ARM_NONE */
> + 3, /* R_ARM_REL32 */
> + 42, /* R_ARM_PREL31 */
> + ],
> + ..Default::default()
> + }
> + .into(),
> _ => None,
> }
> }
[Severity: High]
Does the bindings::EM_ARM allowlist omit valid PC-relative relocations emitted
for arch/arm/vdso/vgettimeofday.o?
When building with Clang (or with CONFIG_THUMB2_KERNEL=y), accessing the
hidden vdso_u_time_data symbol under -march=armv7-a -fPIC uses movw/movt pairs
with R_ARM_MOVW_PREL_NC (45) and R_ARM_MOVT_PREL (46) in ARM mode, or
R_ARM_THM_MOVW_PREL_NC (49) and R_ARM_THM_MOVT_PREL (50) in Thumb-2 mode. In
addition, when static helpers in lib/vdso/gettimeofday.c are not inlined (such
as with CONFIG_DEBUG_SECTION_MISMATCH=y), intra-object calls and tail jumps
emit R_ARM_CALL (28), R_ARM_JUMP24 (29), R_ARM_THM_CALL (10), and
R_ARM_THM_JUMP24 (30). All of these resolve at static link time without
producing dynamic relocations, but vdsocheck rejects vgettimeofday.o and fails
the build.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-vdso-absolute-reloc-v6-0-161e218dd217@linutronix.de?part=3
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 04/11] arm64: vdso: Enable the vdsocheck tool
2026-11-23 13:50 ` [PATCH v6 04/11] arm64: " Thomas Weißschuh
@ 2026-11-24 13:53 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-11-24 13:53 UTC (permalink / raw)
To: Thomas Weißschuh, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Lutomirski, Vincenzo Frascino,
Kees Cook, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Richard Weinberger, Anton Ivanov, Johannes Berg,
Russell King, Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-mm, linux-s390, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] arm64: vdso: missing EM_ARM relocations in
allowed_relocations_for_machine()
- [Low] arm64: vdso32: missing $(vdsocheck) prerequisite for vdso.so.raw
target
- [Low] vdso: vdsocheck: missing R_AARCH64_JUMP26 in
allowed_relocations_for_machine()
- [Low] vdso: vdsocheck: rejection of R_*_NONE relocations in
validate_linked_dso()
--
commit c6172b0bea62f3a614a6024ef180d13da9b4e5c7
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
arm64: vdso: Enable the vdsocheck tool
This commit enables the vdsocheck tool on arm64 by selecting VDSO_CHECK,
updating the arm64 vDSO Makefile link rule, and adding allowed AArch64 object
file relocations to vdsocheck.
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index b5a51b0ef9440..1caaf4737f027 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -258,6 +258,7 @@ config ARM64
> select TRACE_IRQFLAGS_NMI_SUPPORT
> select HAVE_SOFTIRQ_ON_OWN_STACK
> select USER_STACKTRACE_SUPPORT
> + select VDSO_CHECK
[Severity: Medium]
Does selecting VDSO_CHECK break arm64 builds when CONFIG_COMPAT_VDSO and
CONFIG_RUST_IS_AVAILABLE are enabled?
Selecting VDSO_CHECK activates cmd_vdso_check in lib/vdso/Makefile.include for
arch/arm64/kernel/vdso32/ as well. That directory compiles vgettimeofday.c
with -fPIC -march=armv8-a (and -mthumb by default under
CONFIG_THUMB2_COMPAT_VDSO). When __arch_get_vdso_u_time_data() materializes
the address of vdso_u_time_data with Clang, or when the compiler emits
intra-object branches, vgettimeofday.o contains PC-relative ARMv8-A and
Thumb-2 relocations such as R_ARM_THM_MOVW_PREL_NC (49), R_ARM_THM_MOVT_PREL
(50), R_ARM_MOVW_PREL_NC (45), R_ARM_MOVT_PREL (46), R_ARM_THM_CALL (10),
R_ARM_THM_JUMP24 (30), R_ARM_CALL (28), and R_ARM_JUMP24 (29).
In lib/vdso/check/vdsocheck.rs, allowed_relocations_for_machine() only allows
R_ARM_NONE (0), R_ARM_REL32 (3), and R_ARM_PREL31 (42) for bindings::EM_ARM,
so vdsocheck rejects arch/arm64/kernel/vdso32/vgettimeofday.o with
ValidationError::InvalidRelocation.
> diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
> index 7dec05dd33b70..9fac0e54097dc 100644
> --- a/arch/arm64/kernel/vdso/Makefile
> +++ b/arch/arm64/kernel/vdso/Makefile
> @@ -61,7 +61,7 @@ targets += vdso.lds
> CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
>
> # Link rule for the .so file, .lds has to be first
> -$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
> +$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) $(vdsocheck) FORCE
> $(call if_changed,vdsold_and_vdso_check)
[Severity: Low]
Should $(obj)/vdso.so.raw in arch/arm64/kernel/vdso32/Makefile also list
$(vdsocheck) as a prerequisite?
arch/arm64/kernel/vdso32/Makefile runs $(cmd_vdso_check) via
$(call if_changed,vdsold_and_vdso_check), and cmd_vdsold already filters $^ to
%.lds and %.o, but without $(vdsocheck) in the target prerequisites Kbuild
will not re-run the check on the compat vDSO when vdsocheck is rebuilt.
[ ... ]
> diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
> index e28ee59a900dd..0d5ceaca34d7c 100644
> --- a/lib/vdso/check/vdsocheck.rs
> +++ b/lib/vdso/check/vdsocheck.rs
> @@ -57,6 +57,18 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
> ..Default::default()
> }
> .into(),
> + bindings::EM_AARCH64 => AllowedRelocations {
> + in_object_file: &[
> + 260, /* R_AARCH64_PREL64 */
> + 261, /* R_AARCH64_PREL32 */
> + 262, /* R_AARCH64_PREL16 */
> + 273, /* R_AARCH64_LD_PREL_LO19 */
> + 274, /* R_AARCH64_ADR_PREL_LO21 */
> + 283, /* R_AARCH64_CALL26 */
> + ],
> + ..Default::default()
> + }
> + .into(),
[Severity: Low]
Should the bindings::EM_AARCH64 list also allow 282 (R_AARCH64_JUMP26)?
R_AARCH64_CALL26 (283) covers 26-bit PC-relative BL calls, while tail-call
optimization or unconditional branches between functions in an object file
emit B instructions with R_AARCH64_JUMP26 (282), which would otherwise fail
validation with ValidationError::InvalidRelocation.
[Severity: Low]
Can validate_linked_dso() reject valid linked vDSOs when the linker emits
R_*_NONE dynamic relocations?
lib/vdso/Makefile.include notes that some GNU ld ports emit unneeded R_*_NONE
relocations and filters them out with grep -v _NONE when vdsocheck is not
used. When vdsocheck is enabled, validate_linked_dso() rejects any
elf::Section::Rel or elf::Section::Rela section outright without ignoring
R_*_NONE entries.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-vdso-absolute-reloc-v6-0-161e218dd217@linutronix.de?part=4
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 05/11] powerpc/vdso: Enable the vdsocheck tool
2026-11-23 13:50 ` [PATCH v6 05/11] powerpc/vdso: " Thomas Weißschuh
@ 2026-11-24 13:53 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-11-24 13:53 UTC (permalink / raw)
To: Thomas Weißschuh, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Lutomirski, Vincenzo Frascino,
Kees Cook, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Richard Weinberger, Anton Ivanov, Johannes Berg,
Russell King, Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-mm, linux-s390, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] powerpc/vdso: missing PCREL relocations in
allowed_relocations_for_machine()
- [High] powerpc/vdso: unignored .rela.opd in
allowed_relocations_for_machine()
--
commit 52616a4e4f7df565d936b44f34a023f9e1864af3
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
powerpc/vdso: Enable the vdsocheck tool
This commit enables the vdsocheck build-time validation tool for 32-bit and
64-bit PowerPC vDSO objects and defines their allowed ELF relocation types.
> diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
> index 0d5ceaca34d7c..da58ff220eab6 100644
> --- a/lib/vdso/check/vdsocheck.rs
> +++ b/lib/vdso/check/vdsocheck.rs
> @@ -69,6 +69,33 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
> ..Default::default()
> }
> .into(),
> + bindings::EM_PPC => AllowedRelocations {
> + in_object_file: &[
> + 10, /* R_PPC_REL24 */
> + 11, /* R_PPC_REL14 */
> + 26, /* R_PPC_REL32 */
> + 249, /* R_PPC_REL16 */
> + 250, /* R_PPC_REL16_LO */
> + 251, /* R_PPC_REL16_HI */
> + 252, /* R_PPC_REL16_HA */
> + ],
> + ..Default::default()
> + }
> + .into(),
> + bindings::EM_PPC64 => AllowedRelocations {
> + in_object_file: &[
> + 10, /* R_PPC64_REL24 */
> + 11, /* R_PPC64_REL14 */
> + 26, /* R_PPC64_REL32 */
> + 44, /* R_PPC64_REL64 */
> + 249, /* R_PPC64_REL16 */
> + 250, /* R_PPC64_REL16_LO */
> + 251, /* R_PPC64_REL16_HI */
> + 252, /* R_PPC64_REL16_HA */
> + ],
> + ..Default::default()
> + }
> + .into(),
> _ => None,
> }
> }
[Severity: High]
Does the bindings::EM_PPC64 entry break 64-bit vDSO builds when
CONFIG_PPC_KERNEL_PCREL is enabled?
With CONFIG_PPC_KERNEL_PCREL=y, CFUNC() appends @notoc in
arch/powerpc/include/asm/ppc_asm.h, so cvdso_call in gettimeofday.S and
getrandom.S emits R_PPC64_REL24_NOTOC (116). In addition,
vgettimeofday-64.o and vgetrandom-64.o are compiled with KBUILD_CFLAGS
(which includes -mpcrel) and emit R_PPC64_REL24_NOTOC (116) and
R_PPC64_PCREL34 (132), causing vdsocheck to reject the object files and fail
the build.
[Severity: High]
Will vdsocheck also fail the build on 64-bit big-endian kernels using ELFv1
(CONFIG_PPC64_ELF_ABI_V1=y)?
Under -mabi=elfv1, the compiler emits function descriptors in .opd for the
global C functions in vgettimeofday-64.o and vgetrandom-64.o, producing a
.rela.opd section with R_PPC64_ADDR64 (38) and R_PPC64_TOC (51) relocations.
Although arch/powerpc/kernel/vdso/vdso64.lds.S discards *(.opd) during the
final link, vdsocheck runs on the intermediate object files first and
rejects .rela.opd unless it is listed in ignored_object_file_sections.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-vdso-absolute-reloc-v6-0-161e218dd217@linutronix.de?part=5
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 07/11] LoongArch: vDSO: Enable the vdsocheck tool
2026-11-23 13:50 ` [PATCH v6 07/11] LoongArch: vDSO: " Thomas Weißschuh
@ 2026-11-24 13:53 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-11-24 13:53 UTC (permalink / raw)
To: Thomas Weißschuh, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Lutomirski, Vincenzo Frascino,
Kees Cook, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Richard Weinberger, Anton Ivanov, Johannes Berg,
Russell King, Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-mm, linux-s390, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] LoongArch: vDSO: wrong R_LARCH_PCADD_LO12 value in vdsocheck
- [Medium] LoongArch: vDSO: missing relax and eh_frame relocations in
vdsocheck
--
commit 2fb850dc718e09234a1d0b974829df4ce1c9ae9b
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
LoongArch: vDSO: Enable the vdsocheck tool
This commit selects VDSO_CHECK for LoongArch, wires vdsocheck into the
LoongArch vDSO Makefile, and adds the allowed object file relocations for
EM_LOONGARCH.
> diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
> index 37455d3261109..7952ad6ba72b1 100644
> --- a/lib/vdso/check/vdsocheck.rs
> +++ b/lib/vdso/check/vdsocheck.rs
> @@ -122,6 +122,32 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
> ..Default::default()
> }
> .into(),
> + bindings::EM_LOONGARCH => AllowedRelocations {
> + in_object_file: &[
> + 47, /* R_LARCH_ADD8 */
> + 48, /* R_LARCH_ADD16 */
> + 49, /* R_LARCH_ADD24 */
> + 50, /* R_LARCH_ADD32 */
> + 51, /* R_LARCH_ADD64 */
> + 52, /* R_LARCH_SUB8 */
> + 53, /* R_LARCH_SUB16 */
> + 54, /* R_LARCH_SUB24 */
> + 55, /* R_LARCH_SUB32 */
> + 56, /* R_LARCH_SUB64 */
> + 64, /* R_LARCH_B16 */
> + 65, /* R_LARCH_B21 */
> + 66, /* R_LARCH_B26 */
> + 71, /* R_LARCH_PCALA_HI20 */
> + 72, /* R_LARCH_PCALA_LO12 */
> + 73, /* R_LARCH_PCALA64_LO20 */
> + 74, /* R_LARCH_PCALA64_HI12 */
> + 99, /* R_LARCH_32_PCREL */
[Severity: Medium]
Should EM_LOONGARCH also allow R_LARCH_RELAX (100), R_LARCH_ALIGN (102),
R_LARCH_ADD6 (105), and R_LARCH_SUB6 (106)?
arch/loongarch/vdso/Makefile overrides KBUILD_CFLAGS and KBUILD_AFLAGS for
$(obj-vdso) using ccflags-vdso and cflags-vdso, which drops -mno-relax and
-mthin-add-sub from arch/loongarch/Makefile while enabling
-fasynchronous-unwind-tables. As a result, toolchains with linker
relaxation enabled by default emit R_LARCH_RELAX and R_LARCH_ALIGN in the
vDSO objects, and .rela.eh_frame uses R_LARCH_ADD6 and R_LARCH_SUB6 for
DW_CFA_advance_loc, causing vdsocheck to fail the build.
> + 128, /* R_LARCH_PCADD_HI20 */
> + 128, /* R_LARCH_PCADD_LO12 */
[Severity: Medium]
Should R_LARCH_PCADD_LO12 be 129 instead of 128? In
arch/loongarch/include/asm/elf.h, R_LARCH_PCADD_HI20 is 128 and
R_LARCH_PCADD_LO12 is 129, so any vDSO object using pcaddi-based
PC-relative addressing (where the two relocations are emitted as a pair)
will be rejected by vdsocheck with an InvalidRelocation error on 129.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-vdso-absolute-reloc-v6-0-161e218dd217@linutronix.de?part=7
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 09/11] MIPS: vdso: Enable the vdsocheck tool
2026-11-23 13:51 ` [PATCH v6 09/11] MIPS: vdso: " Thomas Weißschuh
@ 2026-11-24 13:53 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-11-24 13:53 UTC (permalink / raw)
To: Thomas Weißschuh, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Lutomirski, Vincenzo Frascino,
Kees Cook, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Richard Weinberger, Anton Ivanov, Johannes Berg,
Russell King, Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-mm, linux-s390, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] vdso: vdsocheck misparses 64-bit MIPS ELF64 r_info relocations
--
commit 2aab3cbfe50b7d8f9c6cf9cb786fc8880a6ac472
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
MIPS: vdso: Enable the vdsocheck tool
This commit enables the vdsocheck tool for MIPS and defines the allowed
object file relocations for EM_MIPS in vdsocheck.
> diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
> index 1ef3f240f886f..120d8fa551e6e 100644
> --- a/lib/vdso/check/vdsocheck.rs
> +++ b/lib/vdso/check/vdsocheck.rs
> @@ -157,6 +157,21 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
> ..Default::default()
> }
> .into(),
> + bindings::EM_MIPS => AllowedRelocations {
> + ignored_object_file_sections: &[".rel.pdr", ".rela.pdr"],
> + in_object_file: &[
> + 10, /* R_MIPS_PC16 */
> + 60, /* R_MIPS_PC21_S2 */
> + 61, /* R_MIPS_PC26_S2 */
> + 62, /* R_MIPS_PC18_S3 */
> + 63, /* R_MIPS_PC19_S2 */
> + 64, /* R_MIPS_PCHI16 */
> + 65, /* R_MIPS_PCLO16 */
> + 248, /* R_MIPS_PC32 */
> + ],
> + ..Default::default()
> + }
> + .into(),
> _ => None,
> }
> }
[Severity: Low]
Does vdsocheck misparse 64-bit EM_MIPS relocation entries in
RelSectionIterator::next() and RelaSectionIterator::next()?
lib/vdso/check/elf.rs:RelSectionIterator::next() {
...
ClassAlternative::Elf64(iter) => iter.next().map(|n| {
let type_ = n.r_info.to_cpu(iter.byteorder) as u32;
Self::Item { type_ }
}),
...
}
Unlike standard ELF64 where r_info is ((r_sym << 32) | r_type), the 64-bit
MIPS ELF ABI lays out the 8-byte r_info region as a 32-bit r_sym at byte
offsets 0..3 followed by 1-byte r_ssym, r_type3, r_type2, and r_type
fields at byte offsets 4..7 (see Elf64_Mips_R_Info in
arch/mips/include/asm/elf.h and get_rel_type_and_sym() in
scripts/mod/modpost.c).
On 64-bit little-endian MIPS (such as 64r6el_defconfig),
n.r_info.to_cpu(iter.byteorder) as u32 reads bytes 0..3, returning r_sym
instead of r_type and causing vdsocheck to fail the build when validating
64-bit vDSO object files whose symbol indices do not match the allowed
relocation numbers. On 64-bit big-endian MIPS, it packs r_ssym, r_type3,
r_type2, and r_type into a single u32 instead of checking the individual
relocation slots.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-vdso-absolute-reloc-v6-0-161e218dd217@linutronix.de?part=9
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 11/11] vDSO: Automatically enable VDSO_CHECK
2026-11-23 13:51 ` [PATCH v6 11/11] vDSO: Automatically enable VDSO_CHECK Thomas Weißschuh
@ 2026-11-24 13:53 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-11-24 13:53 UTC (permalink / raw)
To: Thomas Weißschuh, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Lutomirski, Vincenzo Frascino,
Kees Cook, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Richard Weinberger, Anton Ivanov, Johannes Berg,
Russell King, Catalin Marinas, Will Deacon, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Huacai Chen, WANG Xuerui,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, Thomas Bogendoerfer,
Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Thomas Gleixner, Christophe Leroy, Boqun Feng,
Nicolas Schier
Cc: linux-mm, linux-s390, linux-kbuild, Jan Stancek,
Arnaldo Carvalho de Melo, Peter Zijlstra
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] vdso: VDSO_CHECK disabled on 32-bit RISC-V and some MIPS
configs
--
commit 7179dbe5f048cacac134800666e4651c26c46665
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
vDSO: Automatically enable VDSO_CHECK
This commit selects VDSO_CHECK from GENERIC_GETTIMEOFDAY and VDSO_GETRANDOM
in lib/vdso/Kconfig and removes the per-architecture VDSO_CHECK selects.
[ ... ]
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 9a3ce550c95dc..e2eb9627bd14c 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -107,7 +107,6 @@ config MIPS
> select TRACE_IRQFLAGS_SUPPORT
> select ARCH_HAS_ELFCORE_COMPAT
> select HAVE_ARCH_KCSAN if 64BIT
> - select VDSO_CHECK
>
> config MIPS_FIXUP_BIGPHYS_ADDR
> bool
[ ... ]
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index f580d2afecf7e..f8e26c4bed2ba 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -229,7 +229,6 @@ config RISCV
> select THREAD_INFO_IN_TASK
> select TRACE_IRQFLAGS_SUPPORT
> select UACCESS_MEMCPY if !MMU
> - select VDSO_CHECK if MMU
> select VDSO_DATASTORE if MMU
> select VDSO_GETRANDOM if MMU && 64BIT
> select USER_STACKTRACE_SUPPORT
[ ... ]
> diff --git a/lib/vdso/Kconfig b/lib/vdso/Kconfig
> index 559f5534831e5..741de1abe9237 100644
> --- a/lib/vdso/Kconfig
> +++ b/lib/vdso/Kconfig
> @@ -6,6 +6,7 @@ config VDSO_DATASTORE
> config GENERIC_GETTIMEOFDAY
> bool
> select VDSO_DATASTORE
> + select VDSO_CHECK
> help
> This is a generic implementation of gettimeofday vdso.
> Each architecture that enables this feature has to
> @@ -21,6 +22,7 @@ config GENERIC_VDSO_OVERFLOW_PROTECT
> config VDSO_GETRANDOM
> bool
> select VDSO_DATASTORE
> + select VDSO_CHECK
> help
> Selected by architectures that support vDSO getrandom().
[Severity: Medium]
Does selecting VDSO_CHECK only from GENERIC_GETTIMEOFDAY and VDSO_GETRANDOM
leave VDSO_CHECK disabled on 32-bit RISC-V and on MIPS configurations
without MIPS_GENERIC_GETTIMEOFDAY?
On RISC-V, both GENERIC_GETTIMEOFDAY and VDSO_GETRANDOM depend on MMU &&
64BIT, while 32-bit MMU builds only select VDSO_DATASTORE and still build
arch/riscv/kernel/vdso/ using cmd_vdso_check from lib/vdso/Makefile.include.
Selecting VDSO_CHECK from VDSO_DATASTORE would cover 32-bit RISC-V as well.
On MIPS, arch/mips/vdso/ is built unconditionally and runs cmd_vdso_check,
but GENERIC_GETTIMEOFDAY is only selected when MIPS_GENERIC_GETTIMEOFDAY is
enabled (which depends on CSRC_R4K || CLKSRC_MIPS_GIC), and MIPS does not
select VDSO_DATASTORE or VDSO_GETRANDOM. When MIPS_GENERIC_GETTIMEOFDAY is
disabled, VDSO_CHECK will no longer be enabled and the build will skip
vdsocheck.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-vdso-absolute-reloc-v6-0-161e218dd217@linutronix.de?part=11
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 00/11] vdso: Reject absolute relocations during build
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
` (10 preceding siblings ...)
2026-11-23 13:51 ` [PATCH v6 11/11] vDSO: Automatically enable VDSO_CHECK Thomas Weißschuh
@ 2026-11-24 13:53 ` sashiko-bot
11 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-11-24 13:53 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Sashiko has finished reviewing this 11-patch series:
- Patches 2, 6, 8, and 10: no issues found.
- Patch 1 ("vdso: Add the vdsocheck tool"): 6 potential issues (4
Medium, 2 Low)
- Patch 3 ("ARM: vdso: Enable the vdsocheck tool"): 1 potential issue (1
High)
- Patch 4 ("arm64: vdso: Enable the vdsocheck tool"): 4 potential issues
(1 Medium, 3 Low)
- Patch 5 ("powerpc/vdso: Enable the vdsocheck tool"): 2 potential
issues (2 High)
- Patch 7 ("LoongArch: vDSO: Enable the vdsocheck tool"): 2 potential
issues (2 Medium)
- Patch 9 ("MIPS: vdso: Enable the vdsocheck tool"): 1 potential issue
(1 Low)
- Patch 11 ("vDSO: Automatically enable VDSO_CHECK"): 1 potential issue
(1 Medium)
Detailed reviews have been sent as separate replies to patches 1, 3-5,
7, 9, and 11.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-vdso-absolute-reloc-v6-0-161e218dd217@linutronix.de
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2026-11-24 13:53 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 13:50 [PATCH v6 00/11] vdso: Reject absolute relocations during build Thomas Weißschuh
2026-11-23 13:50 ` [PATCH v6 01/11] vdso: Add the vdsocheck tool Thomas Weißschuh
2026-11-24 13:52 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 02/11] x86/vdso: Enable " Thomas Weißschuh
2026-11-23 13:50 ` [PATCH v6 03/11] ARM: vdso: " Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 04/11] arm64: " Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 05/11] powerpc/vdso: " Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 06/11] riscv: vdso: " Thomas Weißschuh
2026-11-23 13:50 ` [PATCH v6 07/11] LoongArch: vDSO: " Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:50 ` [PATCH v6 08/11] s390/vdso: " Thomas Weißschuh
2026-11-23 13:51 ` [PATCH v6 09/11] MIPS: vdso: " Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-23 13:51 ` [PATCH v6 10/11] sparc: " Thomas Weißschuh
2026-11-23 13:51 ` [PATCH v6 11/11] vDSO: Automatically enable VDSO_CHECK Thomas Weißschuh
2026-11-24 13:53 ` sashiko-bot
2026-11-24 13:53 ` [PATCH v6 00/11] vdso: Reject absolute relocations during build sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox