Patchwork [3.5.y.z,extended,stable] Patch "tty: set_termios/set_termiox should not return -EINTR" has been added to staging queue

mail settings
Submitter Luis Henriques
Date Feb. 26, 2013, 4:13 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/223295/
State New
Headers show


Luis Henriques - Feb. 26, 2013, 4:13 p.m.
This is a note to let you know that I have just added a patch titled

    tty: set_termios/set_termiox should not return -EINTR

to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
which can be found at:;a=shortlog;h=refs/heads/linux-3.5.y-queue

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.5.y.z tree, see



From fc668b920679e347ed80d36da0b1b7c59677b672 Mon Sep 17 00:00:00 2001
From: Oleg Nesterov <>
Date: Tue, 29 Jan 2013 20:07:41 +0100
Subject: [PATCH] tty: set_termios/set_termiox should not return -EINTR

commit 183d95cdd834381c594d3aa801c1f9f9c0c54fa9 upstream.

read command causes bash to abort with double free or corruption (out).

A simple test-case from Roman:

	// Compile the reproducer and send sigchld ti that process.
	// EINTR occurs even if SA_RESTART flag is set.

	void handler(int sig)

	  struct sigaction act;
	  act.sa_handler = handler;
	  act.sa_flags = SA_RESTART;
	  sigaction (SIGCHLD, &act, 0);
	  struct termio ttp;
	  ioctl(0, TCGETA, &ttp);
	    if (ioctl(0, TCSETAW, ttp) < 0)
		if (errno == EINTR)
		  fprintf(stderr, "BUG!"); return(1);

Change set_termios/set_termiox to return -ERESTARTSYS to fix this
particular problem.

I didn't dare to change other EINTR's in drivers/tty/, but they look
equally wrong.

Reported-by: Roman Rakus <>
Reported-by: Lingzhu Xiang <>
Signed-off-by: Oleg Nesterov <>
Cc: Jiri Slaby <>
Signed-off-by: Greg Kroah-Hartman <>
Signed-off-by: Luis Henriques <>
 drivers/tty/tty_ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index a1b9a2f..f8d03da 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -617,7 +617,7 @@  static int set_termios(struct tty_struct *tty, void __user *arg, int opt)
 	if (opt & TERMIOS_WAIT) {
 		tty_wait_until_sent(tty, 0);
 		if (signal_pending(current))
-			return -EINTR;
+			return -ERESTARTSYS;

 	tty_set_termios(tty, &tmp_termios);
@@ -684,7 +684,7 @@  static int set_termiox(struct tty_struct *tty, void __user *arg, int opt)
 	if (opt & TERMIOS_WAIT) {
 		tty_wait_until_sent(tty, 0);
 		if (signal_pending(current))
-			return -EINTR;
+			return -ERESTARTSYS;