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) 28 29setup() 30{ 31 ulimit -c unlimited 32 echo "core" > /proc/sys/kernel/core_pattern 33} 34 35cleanup() 36{ 37 ulimit -c "$CORE_LIMIT" 38 echo "$CORE_PATTERN" > /proc/sys/kernel/core_pattern 39} 40 41vma_report_check() 42{ 43 if [ $(uname -m) = "x86_64" ]; then 44 if LINE=$(grep "vsyscall" /proc/self/maps); then 45 RIGHT="ffffffffff600000-ffffffffff601000[[:space:]][r-]-xp" 46 if echo "$LINE" | grep -q "$RIGHT"; then 47 tst_res TPASS "[vsyscall] reported correctly" 48 else 49 tst_res TFAIL "[vsyscall] reporting wrong" 50 fi 51 fi 52 fi 53 54 rm -rf core* 55 { vma05_vdso; } > /dev/null 2>&1 56 TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\ 57 vma05_vdso ./core* 2> /dev/null) 58 if echo "$TRACE" | grep -qF "??"; then 59 tst_res TFAIL "[vdso] bug not patched" 60 else 61 tst_res TPASS "[vdso] backtrace complete" 62 fi 63} 64 65. tst_test.sh 66tst_run 67