From: sashiko-bot@kernel.org
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
ojeda@kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH v5 12/24] vdso: Add the vdsocheck tool
Date: Tue, 08 Sep 2026 06:57:19 +0000 [thread overview]
Message-ID: <20260908065719.DF3E61F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908-vdso-absolute-reloc-v5-12-3a93791af1cf@linutronix.de>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] Parsing failure for valid ELF files containing `SHT_NOBITS` sections.
- [Medium] `validate_linked_dso` blindly rejects DSOs with `SHT_REL` / `SHT_RELA` sections, dropping the workaround for `R_*_NONE` relocations.
- [Low] Unchecked slice indexing in `get_data_subslice` causes unhandled panics on malformed or adversarial ELF files.
- [Low] vdsocheck.rs fails to compile due to multiple lifetime violations and a move-while-borrowed error.
--
commit 043a7ddfce689ccb30ea6aee60c35639fb8be5b1
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
vdso: Add the vdsocheck tool
This commit introduces a Rust-based vdsocheck tool to validate that the vDSO
library does not contain absolute dynamic relocations, moving this logic out of
inline shell commands.
> diff --git a/lib/vdso/check/elf.rs b/lib/vdso/check/elf.rs
> new file mode 100644
> index 0000000000000..520285d6fd10a
> --- /dev/null
> +++ b/lib/vdso/check/elf.rs
[ ... ]
> +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])
> +}
[Severity: Low]
Does this slice indexing panic if the ELF file specifies an out-of-bounds size
where end exceeds data.len()?
Could this use data.get(start..end).ok_or(...) instead to return a graceful
parsing error rather than failing on malformed ELF files?
[ ... ]
> +impl<'f: 'a, 'a> Iterator for SectionHeaderIterator<'f, 'a> {
> + type Item = ParseResult<SectionHeader<'f>>;
> +
> + fn next(&mut self) -> Option<Self::Item> {
[ ... ]
> + 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(),
> + )?,
> + })
> + }),
[ ... ]
[Severity: Medium]
Will this fail to parse valid ELF files containing sections with no file data
like .bss?
Since sh_size for these sections represents memory allocation size rather than
file size, calling get_data_subslice() here attempts to read non-existent
bytes from the file, which could cause a parsing failure.
[ ... ]
> +impl<'a> RelSection<'a> {
> + pub fn entries(&'a self) -> ParseResult<RelSectionIterator<'a>> {
> + RelSectionIterator::new(&self.0)
> + }
> +}
[Severity: Low]
Does this method signature enforce a lifetime bound (&'a self) that cannot be
satisfied when iterating over locally constructed sections? This appears to
cause a compile failure in validate_object_file().
[ ... ]
> diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
> new file mode 100644
> index 0000000000000..f4c0730bc976d
> --- /dev/null
> +++ b/lib/vdso/check/vdsocheck.rs
[ ... ]
> +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(())
> +}
[Severity: Medium]
Does this blindly reject DSOs containing relocation sections, even if they
solely contain ignored relocations?
The inline shell script this replaces in lib/vdso/Makefile.include explicitly
ignored _NONE relocations:
cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q " R_\w*_"; \
Does unconditionally rejecting all relocation sections drop this workaround for
toolchains that emit empty or _NONE relocations?
[ ... ]
> +fn validate_object_file<'a>(file: &'a elf::File<'a>) -> ValidationResult<'a> {
[ ... ]
> + 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_));
> + }
> + }
> + }
[Severity: Low]
Will this fail to compile due to a move-while-borrowed error?
The variable section is moved into ValidationError::InvalidRelocation while it
is still borrowed by ref rel.
Combined with the lifetime requirements of rel.entries(), this breaks the
build when the vdso check config is enabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908-vdso-absolute-reloc-v5-0-3a93791af1cf@linutronix.de?part=12
next prev parent reply other threads:[~2026-09-08 6:57 UTC|newest]
Thread overview: 130+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 6:33 [PATCH v5 00/24] vdso: Reject absolute relocations during build Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:33 ` [PATCH v5 01/24] elf, uapi: Add a header for relocation constants Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:37 ` sashiko-bot
2026-09-08 9:00 ` Christophe Leroy (CS GROUP)
2026-09-08 9:00 ` Christophe Leroy (CS GROUP)
2026-09-10 6:31 ` Mukesh Kumar Chaurasiya
2026-09-10 6:31 ` Mukesh Kumar Chaurasiya
2026-09-08 6:33 ` [PATCH v5 02/24] x86/elf, um/x86/elf: Move relocation constants to UAPI Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:46 ` sashiko-bot
2026-09-08 13:55 ` Borislav Petkov
2026-09-08 13:55 ` Borislav Petkov
2026-09-08 14:26 ` Thomas Weißschuh
2026-09-08 14:26 ` Thomas Weißschuh
2026-09-08 15:12 ` Borislav Petkov
2026-09-08 15:12 ` Borislav Petkov
2026-09-09 5:59 ` Thomas Weißschuh
2026-09-09 5:59 ` Thomas Weißschuh
2026-09-09 14:49 ` Borislav Petkov
2026-09-09 14:49 ` Borislav Petkov
2026-09-09 19:27 ` H. Peter Anvin
2026-09-09 19:27 ` H. Peter Anvin
2026-09-09 19:47 ` Borislav Petkov
2026-09-09 19:47 ` Borislav Petkov
2026-09-10 8:33 ` Thomas Weißschuh
2026-09-10 8:33 ` Thomas Weißschuh
2026-09-08 14:32 ` Christophe Leroy (CS GROUP)
2026-09-08 14:32 ` Christophe Leroy (CS GROUP)
2026-09-08 6:33 ` [PATCH v5 03/24] ARM: elf: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:39 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 04/24] arm64: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:44 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 05/24] powerpc/elf: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:43 ` sashiko-bot
2026-09-08 9:02 ` Christophe Leroy (CS GROUP)
2026-09-08 9:02 ` Christophe Leroy (CS GROUP)
2026-09-08 14:01 ` R Nageswara Sastry
2026-09-08 14:01 ` R Nageswara Sastry
2026-09-10 6:30 ` Mukesh Kumar Chaurasiya
2026-09-10 6:30 ` Mukesh Kumar Chaurasiya
2026-09-08 6:33 ` [PATCH v5 06/24] riscv: elf: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:45 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 07/24] LoongArch: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:44 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 08/24] s390/elf: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:50 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 09/24] MIPS: ELF: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:48 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 10/24] sparc: elf: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:48 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 11/24] tools headers UAPI: Sync ELF headers with the kernel sources Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:51 ` sashiko-bot
2026-09-08 8:56 ` Christophe Leroy (CS GROUP)
2026-09-08 8:56 ` Christophe Leroy (CS GROUP)
2026-09-08 9:37 ` Thomas Weißschuh
2026-09-08 9:37 ` Thomas Weißschuh
2026-09-08 9:09 ` Christophe Leroy (CS GROUP)
2026-09-08 9:09 ` Christophe Leroy (CS GROUP)
2026-09-08 6:33 ` [PATCH v5 12/24] vdso: Add the vdsocheck tool Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:57 ` sashiko-bot [this message]
2026-09-08 7:19 ` Peter Zijlstra
2026-09-08 7:19 ` Peter Zijlstra
2026-09-08 7:35 ` Thomas Weißschuh
2026-09-08 7:35 ` Thomas Weißschuh
2026-09-08 7:37 ` Peter Zijlstra
2026-09-08 7:37 ` Peter Zijlstra
2026-09-09 19:31 ` H. Peter Anvin
2026-09-09 19:31 ` H. Peter Anvin
2026-09-09 19:38 ` Miguel Ojeda
2026-09-09 19:38 ` Miguel Ojeda
2026-09-10 6:52 ` Mukesh Kumar Chaurasiya
2026-09-10 6:52 ` Mukesh Kumar Chaurasiya
2026-09-08 6:33 ` [PATCH v5 13/24] x86/vdso: Enable " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:00 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 14/24] ARM: vdso: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:01 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 15/24] arm64: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:08 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 16/24] powerpc/elf: Add 32-bit REL16 relocation definitions Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 6:55 ` sashiko-bot
2026-09-08 9:21 ` Christophe Leroy (CS GROUP)
2026-09-08 9:21 ` Christophe Leroy (CS GROUP)
2026-09-08 14:01 ` R Nageswara Sastry
2026-09-08 14:01 ` R Nageswara Sastry
2026-09-08 6:33 ` [PATCH v5 17/24] powerpc/vdso: Enable the vdsocheck tool Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:05 ` sashiko-bot
2026-09-08 14:02 ` R Nageswara Sastry
2026-09-08 14:02 ` R Nageswara Sastry
2026-09-08 14:41 ` Christophe Leroy (CS GROUP)
2026-09-08 14:41 ` Christophe Leroy (CS GROUP)
2026-09-09 6:09 ` Thomas Weißschuh
2026-09-09 6:09 ` Thomas Weißschuh
2026-09-08 6:33 ` [PATCH v5 18/24] riscv: vdso: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:04 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 19/24] LoongArch: vDSO: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:05 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 20/24] s390/vdso: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:06 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 21/24] MIPS: ELF: Add more PC-relative relocation definitions Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:05 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 22/24] MIPS: vdso: Enable the vdsocheck tool Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:20 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 23/24] sparc: " Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:27 ` sashiko-bot
2026-09-08 6:33 ` [PATCH v5 24/24] vDSO: Automatically enable VDSO_CHECK Thomas Weißschuh
2026-09-08 6:33 ` Thomas Weißschuh
2026-09-08 7:18 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260908065719.DF3E61F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=thomas.weissschuh@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.