From: Kanru Chen <koster@debian.org.tw>
To: linux-kernel@vger.kernel.org
Cc: alan@lxorguk.ukuu.org.uk, Kanru Chen <koster@debian.org.tw>
Subject: [PATCH] tty_io: fix tiocswinsz, tiocgwinsz races.
Date: Fri, 8 Aug 2008 18:36:18 +0800 [thread overview]
Message-ID: <1218191778-5781-1-git-send-email-koster@debian.org.tw> (raw)
real_tty may receive SIGWINCH before the new winsize is setted.
Signed-off-by: Kanru Chen <koster@debian.org.tw>
---
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
next reply other threads:[~2008-08-08 10:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-08 10:36 Kanru Chen [this message]
2008-08-08 11:50 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1218191778-5781-1-git-send-email-koster@debian.org.tw \
--to=koster@debian.org.tw \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®