Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tty: skip ioctl(TIOCSLCKTRMIOS) if possible #2311

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions criu/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,26 @@ static int do_restore_tty_parms(void *arg, int fd, pid_t pid)
* on termios too. Just to be on the safe side.
*/

if ((p->has & HAS_TERMIOS_L) && ioctl(fd, TIOCSLCKTRMIOS, &p->tl) < 0)
goto err;
if ((p->has & HAS_TERMIOS_L) && ioctl(fd, TIOCSLCKTRMIOS, &p->tl) < 0) {
struct termios t;

if (errno != EPERM)
goto err;

memzero(&t, sizeof(t));
if (ioctl(fd, TIOCGLCKTRMIOS, &t) < 0) {
pr_perror("Can't get tty locked params on %#x", p->tty_id);
goto err;
}

/*
* The ioctl(TIOCSLCKTRMIOS) requires a CRIU process to be privileged
* in the init_user_ns, but if the current "termios_locked" value equal
* to the "termios_locked" value from the image, we can safely skip setting it.
*/
if (memcmp(&t, &p->tl, sizeof(struct termios)) != 0)
goto err;
}

if ((p->has & HAS_TERMIOS) && ioctl(fd, TCSETS, &p->t) < 0)
goto err;
Expand Down
Loading