[CRIU] [PATCH] tty: open all terminals with O_NOCTTY

Andrey Vagin avagin at openvz.org
Mon Nov 16 01:06:10 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

Otherwise the kernel can set it as a control terminal for the currect
session and CRIU will not be able to set it as a control terminal for
the target process.

Reported-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 tty.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tty.c b/tty.c
index 3f1bc18..41a374b 100644
--- a/tty.c
+++ b/tty.c
@@ -476,6 +476,7 @@ static void pty_free_fake_reg(struct reg_file_info **r)
 
 static int open_tty_reg(struct file_desc *reg_d, u32 flags)
 {
+	flags |= O_NOCTTY; /* never set as a control terminal automatically */
 	return open_path(reg_d, do_open_reg_noseek_flags, &flags);
 }
 
@@ -772,7 +773,7 @@ static int pty_open_slaves(struct tty_info *info)
 	list_for_each_entry(slave, &info->sibling, sibling) {
 		BUG_ON(tty_is_master(slave));
 
-		fd = open_tty_reg(slave->reg_d, slave->tfe->flags | O_NOCTTY);
+		fd = open_tty_reg(slave->reg_d, slave->tfe->flags);
 		if (fd < 0) {
 			pr_perror("Can't open slave %s", path_from_reg(slave->reg_d));
 			goto err;
@@ -854,7 +855,7 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
 
 		unlock_pty(master);
 
-		fd = open_tty_reg(slave->reg_d, slave->tfe->flags | O_NOCTTY);
+		fd = open_tty_reg(slave->reg_d, slave->tfe->flags);
 		if (fd < 0) {
 			pr_perror("Can't open slave %s", path_from_reg(slave->reg_d));
 			goto err;
-- 
2.4.3



More information about the CRIU mailing list