• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (C) 2017 Red Hat, Inc.
4# Copyright (C) 2024 Cyril Hrubis <chrubis@suse.cz>
5#
6# ---
7# doc
8#
9# [Description]
10#
11# Regression test if the vsyscall and vdso VMA regions are reported correctly.
12#
13# While [vsyscall] is mostly deprecated with newer systems, there is
14# still plenty of kernels compiled with CONFIG_LEGACY_VSYSCALL_NATIVE and
15# CONFIG_LEGACY_VSYSCALL_EMULATE (see linux/arch/x86/Kconfig for option
16# descriptions). First part of the test will check eligible kernels for
17# regression for a bug fixed by commit 103efcd9aac1 (fix perms/range of
18# vsyscall vma in /proc/*/maps).
19#
20# Second part of test checks [vdso] VMA permissions (fixed with commits
21# b6558c4a2378 (fix [vdso] page permissions) and e5b97dde514f (Add
22# VM_ALWAYSDUMP)). As a consequence of this bug, VMAs were not included
23# in core dumps which resulted in eg. incomplete backtraces and invalid
24# core dump files created by gdb.
25# ---
26#
27# ---
28# env
29# {
30#  "needs_root": true,
31#  "needs_tmpdir": true,
32#  "needs_cmds": ["gdb", "uname"],
33#  "save_restore": [
34#   ["/proc/sys/kernel/core_pattern", "core", "TBROK"],
35#   ["/proc/sys/kernel/core_uses_pid", "0", "TBROK"]
36#  ],
37#  "tags": [
38#   ["linux-git", "103efcd9aac1"],
39#   ["linux-git", "b6558c4a2378"],
40#   ["linux-git", "e5b97dde514f"]
41#  ]
42# }
43# ---
44
45. tst_loader.sh
46
47ulimit -c unlimited
48unset DEBUGINFOD_URLS
49
50if [ $(uname -m) = "x86_64" ]; then
51	if LINE=$(grep "vsyscall" /proc/self/maps); then
52		RIGHT="ffffffffff600000-ffffffffff601000[[:space:]][r-]-xp"
53		if echo "$LINE" | grep -q "$RIGHT"; then
54			tst_res TPASS "[vsyscall] reported correctly"
55		else
56			tst_res TFAIL "[vsyscall] reporting wrong"
57		fi
58	fi
59fi
60
61rm -rf core*
62{ vma05_vdso; } > /dev/null 2>&1
63[ -f core ] || tst_brk TBROK "missing core file"
64
65TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\
66	vma05_vdso ./core* 2> /dev/null)
67
68if echo "$TRACE" | grep -qF "??"; then
69	tst_res TFAIL "[vdso] bug not patched"
70else
71	tst_res TPASS "[vdso] backtrace complete"
72fi
73