Commit 8b9e18f0 authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Pavel Emelyanov

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: 's avatarPavel Tikhomirov <ptikhomirov@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2f857274
...@@ -25,6 +25,7 @@ static/maps01 ...@@ -25,6 +25,7 @@ static/maps01
static/maps02 static/maps02
static/maps04 static/maps04
static/maps05 static/maps05
static/mlock_setuid
static/maps_file_prot static/maps_file_prot
static/mprotect00 static/mprotect00
static/mtime_mmap static/mtime_mmap
...@@ -203,6 +204,7 @@ TEST_SUID_LIST=" ...@@ -203,6 +204,7 @@ TEST_SUID_LIST="
pid00 pid00
caps00 caps00
maps01 maps01
mlock_setuid
groups groups
sched_prio00 sched_prio00
sched_policy00 sched_policy00
......
...@@ -70,6 +70,7 @@ TST_NOFILE = \ ...@@ -70,6 +70,7 @@ TST_NOFILE = \
maps03 \ maps03 \
maps04 \ maps04 \
maps05 \ maps05 \
mlock_setuid \
xids00 \ xids00 \
groups \ groups \
pdeath_sig \ pdeath_sig \
...@@ -290,6 +291,7 @@ sigpending: override LDLIBS += -lrt ...@@ -290,6 +291,7 @@ sigpending: override LDLIBS += -lrt
vdso01: override LDLIBS += -lrt vdso01: override LDLIBS += -lrt
mntns_link_remap: override CFLAGS += -DZDTM_LINK_REMAP mntns_link_remap: override CFLAGS += -DZDTM_LINK_REMAP
maps02: get_smaps_bits.o maps02: get_smaps_bits.o
mlock_setuid: get_smaps_bits.o
$(LIB): force $(LIB): force
$(Q) $(MAKE) -C $(LIBDIR) $(Q) $(MAKE) -C $(LIBDIR)
......
#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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment