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