mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +00:00
zdtm: test for mlocked area restores if programm have no credentials
Test maps 17 pages and mlocks them, then changes user id from root to 18943, after c/r checks that MAP_LOCKED bit is set for that vma. Signed-off-by: Pavel Tikhomirov <ptikhomirov@parallels.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
2f85727410
commit
8b9e18f07b
@@ -25,6 +25,7 @@ static/maps01
|
||||
static/maps02
|
||||
static/maps04
|
||||
static/maps05
|
||||
static/mlock_setuid
|
||||
static/maps_file_prot
|
||||
static/mprotect00
|
||||
static/mtime_mmap
|
||||
@@ -203,6 +204,7 @@ TEST_SUID_LIST="
|
||||
pid00
|
||||
caps00
|
||||
maps01
|
||||
mlock_setuid
|
||||
groups
|
||||
sched_prio00
|
||||
sched_policy00
|
||||
|
@@ -70,6 +70,7 @@ TST_NOFILE = \
|
||||
maps03 \
|
||||
maps04 \
|
||||
maps05 \
|
||||
mlock_setuid \
|
||||
xids00 \
|
||||
groups \
|
||||
pdeath_sig \
|
||||
@@ -290,6 +291,7 @@ sigpending: override LDLIBS += -lrt
|
||||
vdso01: override LDLIBS += -lrt
|
||||
mntns_link_remap: override CFLAGS += -DZDTM_LINK_REMAP
|
||||
maps02: get_smaps_bits.o
|
||||
mlock_setuid: get_smaps_bits.o
|
||||
|
||||
$(LIB): force
|
||||
$(Q) $(MAKE) -C $(LIBDIR)
|
||||
|
55
test/zdtm/live/static/mlock_setuid.c
Normal file
55
test/zdtm/live/static/mlock_setuid.c
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include "zdtmtst.h"
|
||||
|
||||
#define MEM_SIZE (69632)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
void *start;
|
||||
unsigned long new_flags = 0;
|
||||
unsigned long new_madv = 0;
|
||||
test_init(argc, argv);
|
||||
|
||||
test_msg("Alloc vma of size %d\n", MEM_SIZE);
|
||||
start = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
if (start == MAP_FAILED) {
|
||||
err("mmap failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
test_msg("Lock vma from %lx to %lx\n", start, start + MEM_SIZE);
|
||||
ret = mlock(start, MEM_SIZE);
|
||||
if (ret < 0) {
|
||||
err("mlock");
|
||||
return -1;
|
||||
}
|
||||
|
||||
test_daemon();
|
||||
|
||||
test_msg("Setuid to 18943\n");
|
||||
ret = setuid(18943);
|
||||
if (ret < 0) {
|
||||
err("setuid");
|
||||
return -1;
|
||||
}
|
||||
|
||||
test_waitsig();
|
||||
|
||||
ret = get_smaps_bits((unsigned long)start, &new_flags, &new_madv);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
test_msg("Check smaps flags for MAP_LOCKED\n");
|
||||
if (new_flags & MAP_LOCKED) {
|
||||
pass();
|
||||
} else {
|
||||
fail("Vma is not locked after c/r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user