Commit 1176081e authored by Filipe Brandenburger's avatar Filipe Brandenburger Committed by Pavel Emelyanov

zdtm: add new dumpable01 test to check that dumpable flag is preserved

This confirms that the fix in commit d5bb7e97 to preserve the dumpable flag
after migration is working as expected.

In this test case, the dumpable flag is expected to always be set to 1, as
test_init will use prctl to reset it to 1 after using setuid and setgid.

Tested:
- # test/zdtm.sh static/dumpable01
  Test: zdtm/live/static/dumpable01, Result: PASS
- # test/zdtm.sh ns/static/dumpable01
  Test: zdtm/live/static/dumpable01, Result: PASS
- Confirmed that the test fails after reverting commit d5bb7e97.
Signed-off-by: 's avatarFilipe Brandenburger <filbranden@google.com>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7f3de288
......@@ -107,6 +107,7 @@ static/chroot
static/chroot-file
static/rtc
transition/maps007
static/dumpable01
"
# Duplicate list with ns/ prefix
TEST_LIST=$TEST_LIST$(echo $TEST_LIST | tr ' ' '\n' | sed 's#^#ns/#')
......
......@@ -15,6 +15,7 @@
/live/static/cwd01
/live/static/deleted_dev
/live/static/deleted_unix_sock
/live/static/dumpable01
/live/static/env00
/live/static/eventfs00
/live/static/fanotify00
......
......@@ -109,6 +109,7 @@ TST_NOFILE = \
stopped \
rtc \
clean_mntns \
dumpable01 \
# jobctl00 \
TST_FILE = \
......
#include <sys/prctl.h>
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include "zdtmtst.h"
const char *test_doc = "Check dumpable flag handling (dumpable case)";
const char *test_author = "Filipe Brandenburger <filbranden@google.com>";
int main(int argc, char **argv)
{
int save_dumpable;
int dumpable;
test_init(argc, argv);
save_dumpable = prctl(PR_GET_DUMPABLE);
if (save_dumpable < 0) {
err("error getting prctl(PR_GET_DUMPABLE) before dump");
return 1;
}
#ifdef DEBUG
test_msg("DEBUG: before dump: dumpable=%d\n", save_dumpable);
#endif
/* Wait for criu dump and restore. */
test_daemon();
test_waitsig();
dumpable = prctl(PR_GET_DUMPABLE);
if (dumpable < 0) {
err("error getting prctl(PR_GET_DUMPABLE) after restore");
return 1;
}
#ifdef DEBUG
test_msg("DEBUG: after dump: dumpable=%d\n", dumpable);
#endif
if (dumpable != save_dumpable) {
errno = 0;
fail("dumpable flag was not preserved over migration");
return 1;
}
pass();
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