[CRIU] [PATCH] restore: unset dumpable flag for zombies (v2)

Andrew Vagin avagin at openvz.org
Tue Aug 6 10:45:36 EDT 2013


We have already tried to prevent generating core files for zombies:

commit 6da52216ce8e47fed0ded1c5a451968ef7c177a2
Author: Andrey Vagin <avagin at openvz.org>
Date:   Fri Jul 12 18:14:23 2013 +0400

    restore: set the zero limit for RLIMIT_CORE

But it doesn't work if a core file is sent into a pipe.
This functionality is used by the abrt daemon for example.

This patch uses more direct way, it unsets the dumpable flag with help
of PR_SET_DUMPABLE.

v2: remove the previous hack

Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 cr-restore.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index b06e3b9..5c6e4bb 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -19,6 +19,7 @@
 #include <sys/file.h>
 #include <sys/shm.h>
 #include <sys/mount.h>
+#include <sys/prctl.h>
 
 #include <sched.h>
 
@@ -749,12 +750,11 @@ static int restore_one_zombie(int pid, CoreEntry *core)
 	}
 
 	if (exit_code & 0x7f) {
-		struct rlimit rlim = {0, 0};
 		int signr;
 
 		/* prevent generating core files */
-		if (setrlimit(RLIMIT_CORE, &rlim))
-			pr_perror("Can't set the zero limit for core files");
+		if (prctl(PR_SET_DUMPABLE, 0, 0, 0, 0))
+			pr_perror("Can't drop the dumpable flag");
 
 		signr = exit_code & 0x7F;
 		if (!sig_fatal(signr)) {
-- 
1.8.3.1



More information about the CRIU mailing list