From: "Adam Tlałka" <atlka@pg.gda.pl>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: 7eggert@gmx.de, linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: Re: [PATCH 0/2] SIGWINCH problem with terminal apps still alive
Date: Sun, 12 Oct 2008 19:59:57 +0200 [thread overview]
Message-ID: <20081012195957.50feada3@merlin.oi.pg.gda.pl> (raw)
In-Reply-To: <20081012152200.4a8f14c4@lxorguk.ukuu.org.uk>
Sun, 12 Oct 2008 15:22:00 +0100 - Alan Cox <alan@lxorguk.ukuu.org.uk>:
> O> real_tty structures. TIOCSWINSZ and TIOCGWINSZ ioctls could be
> > called on tty and real_tty at the same time. To avoid race condition
>
> No they can't. Would you please bother to spend five minutes actually
> reading the source code and following through your assumptions to see
> if they make sense before posting.
>
> tiocgwinsz is never called for the pty side of a pty pair.
I've read the code. The race problem with xterm or other pty using
program in 2.6.26 appeared because one app called ioctl(TIOCSWINSZ) on
the master side while other read winsize (TIOCGWINSZ) using client side
(slave). So in one ioctl() call tty == master and in other tty ==
real_tty. Of course we can have the opposite situaction so terminal app
is using ioctl(TIOCSWINSZ) on its side (slave) and xterm is using ioctl
on its side to know to which size resize itself. Not working now as I
tested but possible.
Anyway I think that you miss the point. Why using
real_tty->termios_mutex instead of tty->termios_mutex in tty_do_resize
called from tiocswins() so from ioctl(TIOCSWINSZ) closes the race. If as
you said tiocgwinsz is called on tty and not real_tty then
tty->termios_mutex should be valid here.
Mutexes work and it is not a scheduler problem as I wrongly assumed.
The scheduler just exposed this problem doing an app switch.
It's just wrong mutex used.
Look at the tty_ioctl(struct file *file, unsigned int cmd, unsigned
long arg) in tty_io.c.
tty = (struct tty_struct *)file->private_data;
so if you calling ioctl on master side we have tty = master
and on client side tty = real_tty in ioctl entry;
next
real_tty = tty;
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
tty->driver->subtype == PTY_TYPE_MASTER)
real_tty = tty->link;
if tty is the master one we set real_tty but in case of client side
tty == real_tty already so real_tty points to the same structure.
So it seems that tty->termios_mutex could point to different
location in different calls but real_tty->termios_mutex always points
to the same location.
Regards
--
Adam Tlałka mailto:atlka@pg.gda.pl ^v^ ^v^ ^v^
System & Network Administration Group - - - ~~~~~~
Computer Center, Gdańsk University of Technology, Poland
next prev parent reply other threads:[~2008-10-12 18:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bjXel-4CU-17@gated-at.bofh.it>
[not found] ` <bjYap-5Q0-25@gated-at.bofh.it>
[not found] ` <bk30i-3Gx-1@gated-at.bofh.it>
[not found] ` <bk6AV-8ms-7@gated-at.bofh.it>
[not found] ` <bkrvO-1HF-49@gated-at.bofh.it>
[not found] ` <blePJ-6rI-3@gated-at.bofh.it>
[not found] ` <blmDC-7ZU-7@gated-at.bofh.it>
2008-10-11 14:04 ` [PATCH 0/1] " Bodo Eggert
2008-10-11 17:58 ` Alan Cox
2008-10-12 12:32 ` [PATCH 0/2] " Adam Tlałka
2008-10-12 14:22 ` Alan Cox
2008-10-12 17:59 ` Adam Tlałka [this message]
2008-10-12 18:03 ` Alan Cox
2008-10-12 19:01 ` Adam Tlałka
2008-10-12 20:22 ` Alan Cox
2008-10-13 9:59 ` Bodo Eggert
2008-10-13 10:01 ` Alan Cox
2008-10-13 12:07 ` Bodo Eggert
2008-10-14 12:51 ` [PATCH 0/3] " Adam Tlałka
2008-10-14 14:11 ` [PATCH 0/4] " Adam Tlałka
2008-10-16 10:27 ` [PATCH 0/5] " Adam Tlałka
2008-10-16 10:52 ` Alan Cox
2008-10-16 11:43 ` Adam Tlałka
2008-10-17 8:39 ` Adam Tlałka
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=20081012195957.50feada3@merlin.oi.pg.gda.pl \
--to=atlka@pg.gda.pl \
--cc=7eggert@gmx.de \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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®