Commit 1a86283b authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

tty: open all terminals with O_NOCTTY

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: 's avatarAndrey Ryabinin <aryabinin@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent bea76a01
...@@ -476,6 +476,11 @@ static void pty_free_fake_reg(struct reg_file_info **r) ...@@ -476,6 +476,11 @@ static void pty_free_fake_reg(struct reg_file_info **r)
static int open_tty_reg(struct file_desc *reg_d, u32 flags) static int open_tty_reg(struct file_desc *reg_d, u32 flags)
{ {
/*
* Never set as a control terminal automatically, all
* ctty magic happens only in tty_set_sid().
*/
flags |= O_NOCTTY;
return open_path(reg_d, do_open_reg_noseek_flags, &flags); return open_path(reg_d, do_open_reg_noseek_flags, &flags);
} }
...@@ -772,7 +777,7 @@ static int pty_open_slaves(struct tty_info *info) ...@@ -772,7 +777,7 @@ static int pty_open_slaves(struct tty_info *info)
list_for_each_entry(slave, &info->sibling, sibling) { list_for_each_entry(slave, &info->sibling, sibling) {
BUG_ON(tty_is_master(slave)); 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) { if (fd < 0) {
pr_perror("Can't open slave %s", path_from_reg(slave->reg_d)); pr_perror("Can't open slave %s", path_from_reg(slave->reg_d));
goto err; goto err;
...@@ -854,7 +859,7 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave) ...@@ -854,7 +859,7 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
unlock_pty(master); 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) { if (fd < 0) {
pr_perror("Can't open slave %s", path_from_reg(slave->reg_d)); pr_perror("Can't open slave %s", path_from_reg(slave->reg_d));
goto err; goto err;
......
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