Commit e09f7ea0 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

zdtm: set the dumpable flag after setuid (v2)

Otherwise we will not able to access /proc/pid/* for the process.

v2: s/__NR_WAIT4/__NR_setresuid

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7c11b0b9
......@@ -97,7 +97,12 @@ int main(int argc, char ** argv)
if (filter_syscall(__NR_ptrace) < 0)
_exit(1);
if (filter_syscall(__NR_prctl) < 0)
/*
* The idea is to have a syscall that is used in restore_creds,
* so we can make sure seccomp is actually suspended when that
* is called.
*/
if (filter_syscall(__NR_setresuid) < 0)
_exit(1);
setuid(1000);
......@@ -115,6 +120,18 @@ int main(int argc, char ** argv)
_exit(1);
}
prctl(PR_SET_DUMPABLE, 1);
if (write(sk, &c, 1) != 1) {
pr_perror("write");
_exit(1);
}
if (read(sk, &c, 1) != 1) {
pr_perror("read");
_exit(1);
}
/* We expect to be killed by our policy above. */
ptrace(PTRACE_TRACEME);
......@@ -132,6 +149,15 @@ int main(int argc, char ** argv)
test_daemon();
test_waitsig();
if (write(sk, &c, 1) != 1) {
pr_perror("write");
goto err;
}
if ((ret = read(sk, &c, 1)) != 1) {
pr_perror("read %d", ret);
goto err;
}
mode = get_seccomp_mode(pid);
if (write(sk, &c, 1) != 1) {
pr_perror("write");
......
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