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