1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
lvm2/test/shell/dmsecuretest.sh

83 lines
2.2 KiB
Bash
Raw Normal View History

2018-11-17 00:15:23 +03:00
#!/usr/bin/env bash
# Copyright (C) 2018 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Test secure table is not leaking data in user land
SKIP_WITH_LVMPOLLD=1
SKIP_WITH_LVMLOCKD=1
2018-11-17 00:15:23 +03:00
# AES key matching rot13 string from dmsecuretest.c */
SECURE="434e0cbab02ca68ffba9268222c3789d703fe62427b78b308518b3228f6a2122"
. lib/inittest
DMTEST="${PREFIX}-test-secure"
# Test needs installed gdb package with gcore app
which gcore || skip
2018-11-17 00:15:23 +03:00
aux driver_at_least 4 6 || skip
# ensure we can create devices (uses dmsetup, etc)
aux prepare_devs 1
# check both code versions - linked libdm and internal device_mapper version
# there should not be any difference
for i in securetest dmsecuretest ; do
# 1st. try with empty table
# 2nd. retry with already exiting DM node - exercize error path also wipes
for j in empty existing ; do
rm -f cmdout
2018-11-17 00:15:23 +03:00
"$i" "$dev1" "$DMTEST" >cmdout 2>&1 &
PID=$!
2023-10-26 22:58:55 +03:00
for k in $(seq 1 20); do
sleep .1
2023-10-15 22:42:20 +03:00
lines=$(wc -l < cmdout 2>/dev/null || true)
test "${lines:-0}" = "0" || break
done
2018-11-17 00:15:23 +03:00
2023-10-13 02:49:04 +03:00
# 0 8192 crypt aes-xts-plain64 434e0cbab02ca68ffba9268222c3789d703fe62427b78b308518b3228f6a2122 0 253:0 8192
2018-11-17 00:15:23 +03:00
# crypt device should be loaded
2018-11-23 22:18:22 +03:00
dmsetup status "$DMTEST"
2018-11-17 00:15:23 +03:00
# generate core file for running&sleeping binary
gcore "$PID" | tee out || skip
# check we capture core while dmsecuretest was already sleeping
2023-10-15 22:42:20 +03:00
grep -e "nanosleep\|kernel_vsyscall" out
2018-11-23 22:18:22 +03:00
kill "$PID" || true
2018-11-17 00:15:23 +03:00
wait
cat cmdout
# $SECURE string must NOT be present in core file
not grep "$SECURE" "core.$PID" || {
## cp "core.$PID" /dev/shm/core
should dmsetup remove "$DMTEST" # go around weird bugs
2018-11-17 00:15:23 +03:00
die "!!! Secure string $SECURE found present in core.$PID !!!"
}
rm -f "core.$PID"
if test "$j" = empty ; then
not grep "Device or resource busy" cmdout
else
# Device should be already present resulting into error message
grep "Device or resource busy" cmdout
dmsetup remove "$DMTEST"
fi
done
done