Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756901AbYHHK6R (ORCPT ); Fri, 8 Aug 2008 06:58:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754281AbYHHK6H (ORCPT ); Fri, 8 Aug 2008 06:58:07 -0400 Received: from msr4.hinet.net ([168.95.4.104]:47948 "EHLO msr4.hinet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754212AbYHHK6G (ORCPT ); Fri, 8 Aug 2008 06:58:06 -0400 X-Greylist: delayed 1296 seconds by postgrey-1.27 at vger.kernel.org; Fri, 08 Aug 2008 06:58:05 EDT From: Kanru Chen To: linux-kernel@vger.kernel.org Cc: alan@lxorguk.ukuu.org.uk, Kanru Chen Subject: [PATCH] tty_io: fix tiocswinsz, tiocgwinsz races. Date: Fri, 8 Aug 2008 18:36:18 +0800 Message-Id: <1218191778-5781-1-git-send-email-koster@debian.org.tw> X-Mailer: git-send-email 1.5.6.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1170 Lines: 37 real_tty may receive SIGWINCH before the new winsize is setted. Signed-off-by: Kanru Chen --- drivers/char/tty_io.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index e1b46bc..63703ea 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2523,6 +2523,8 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, return -EFAULT; mutex_lock(&tty->termios_mutex); + if (real_tty != tty) + mutex_lock(&real_tty->termios_mutex); if (!memcmp(&tmp_ws, &tty->winsize, sizeof(*arg))) goto done; @@ -2553,6 +2555,8 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, tty->winsize = tmp_ws; real_tty->winsize = tmp_ws; done: + if (real_tty != tty) + mutex_unlock(&real_tty->termios_mutex); mutex_unlock(&tty->termios_mutex); return 0; } -- 1.5.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/