From: "Vegard Nossum" <vegard.nossum@gmail.com>
To: "Alan Cox" <alan@lxorguk.ukuu.org.uk>
Cc: "David Newall" <davidn@davidnewall.com>,
"Willy Tarreau" <w@1wt.eu>,
"Harald Dunkel" <harald.dunkel@t-online.de>,
"Joe Peterson" <joe@skyrush.com>,
linux-kernel@vger.kernel.org, "Alan Cox" <alan@redhat.com>
Subject: Re: 2.6.25.3: su gets stuck for root
Date: Mon, 2 Jun 2008 12:16:56 +0200 [thread overview]
Message-ID: <19f34abd0806020316v4135935dxff04bcf663ebd4bf@mail.gmail.com> (raw)
In-Reply-To: <20080602102033.63e4cd18@core>
[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]
On Mon, Jun 2, 2008 at 11:20 AM, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> On Mon, 02 Jun 2008 18:31:34 +0930
> David Newall <davidn@davidnewall.com> wrote:
>
>> Alan Cox wrote:
>> > Not really. The task would get suspended if it attempted to change the
>> > tty settings while not being session leader. This is part of the POSIX
>> > and BSD job control.
>>
>> I haven't heard about this new restriction, but it begs the observation
>> that stty, when forked from a shell (the usual case), is never a session
>> leader.
>
> Sorry I mean part of the current session. I was thinking about the
> specific case of bash or the ssh->bash setup where the question would be
> whether the shell was session leader.
>
> Someone who can dup this needs to instrument it in tty_ioctl really.
Hi,
I have written a short test program that seems to reproduce it for me
(see attachment), even though the original su/stty stuff wouldn't.
Basically, the strace shows this:
ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 opost isig icanon echo
...}) = ? ERESTARTSYS (To be restarted)
--- SIGTTOU (Stopped (tty output)) @ 0 (0) ---
--- SIGTTOU (Stopped (tty output)) @ 0 (0) ---
ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 opost isig icanon echo
...}) = ? ERESTARTSYS (To be restarted)
--- SIGTTOU (Stopped (tty output)) @ 0 (0) ---
--- SIGTTOU (Stopped (tty output)) @ 0 (0) ---
... (repeating)
The exact code path triggering this seems to be:
tcsetattr() -> ioctl(TCSETS) -> set_termios() -> tty_check_change()
This is on a 2.6.24.5-85.fc8 kernel.
I don't know what's wrong, but I hope this helps.
Vegard
--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: reproduce.c --]
[-- Type: text/x-csrc; name=reproduce.c, Size: 1077 bytes --]
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
pid_t child;
printf("pgid = %d\n", getpgrp());
child = fork();
if (child == 0) {
struct termios termios_p;
printf("forked, pgid = %d\n", getpgrp());
if (setpgrp() == -1) {
printf("error: setpgid: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
printf("new pgid = %d\n", getpgrp());
if (tcgetattr(STDIN_FILENO, &termios_p) == -1) {
printf("error: tcgetattr: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
if (tcsetattr(STDIN_FILENO, 0, &termios_p) == -1) {
printf("error: tcsetattr: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
printf("forked, child = %d\n", child);
while (1) {
pid_t pid;
int status;
pid = wait(&status);
if (pid == -1) {
printf("error: wait: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
printf("pid %d status %d\n", pid, status);
}
return EXIT_SUCCESS;
}
next prev parent reply other threads:[~2008-06-02 10:17 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-02 1:31 Joe Peterson
2008-06-02 5:12 ` Harald Dunkel
2008-06-02 5:32 ` Willy Tarreau
2008-06-02 5:55 ` Joe Peterson
2008-06-02 8:10 ` Alan Cox
2008-06-02 9:01 ` David Newall
2008-06-02 9:20 ` Alan Cox
2008-06-02 10:16 ` Vegard Nossum [this message]
2008-06-02 10:39 ` Vegard Nossum
2008-06-02 10:52 ` Alan Cox
2008-06-02 10:57 ` Vegard Nossum
2008-06-02 12:28 ` Alan Cox
2008-06-02 14:31 ` Vegard Nossum
2008-06-02 10:50 ` Alan Cox
2008-06-17 15:32 ` Joe Peterson
2008-06-02 15:26 ` Joe Peterson
2008-06-02 15:51 ` Alan Cox
2008-06-02 16:03 ` Joe Peterson
2008-06-04 14:43 ` Joe Peterson
2008-06-04 15:16 ` Alan Cox
2008-06-04 16:52 ` Joe Peterson
2008-06-04 17:10 ` Alan Cox
2008-06-04 20:32 ` Joe Peterson
2008-06-11 14:04 ` Joe Peterson
2008-06-12 11:52 ` Vegard Nossum
2008-06-14 1:49 ` Joe Peterson
2008-06-14 7:45 ` Vegard Nossum
2008-06-14 17:43 ` Joe Peterson
2008-06-14 20:34 ` Vegard Nossum
2008-06-14 20:52 ` Joe Peterson
2008-06-14 21:26 ` Vegard Nossum
2008-06-14 21:34 ` Joe Peterson
2008-07-02 18:03 ` tty session leader issue (was Re: 2.6.25.3: su gets stuck for root) Joe Peterson
2008-07-02 19:21 ` markus reichelt
2008-07-06 14:08 ` Tim Connors
2008-07-06 16:44 ` Alan Cox
2008-07-06 18:49 ` tty session leader issue [cause now known!] " Joe Peterson
2008-06-02 5:42 ` 2.6.25.3: su gets stuck for root Joe Peterson
-- strict thread matches above, loose matches on Subject: below --
2008-05-13 6:17 Harald Dunkel
2008-05-13 6:47 ` Vegard Nossum
2008-05-13 17:43 ` Harald Dunkel
2008-05-13 19:46 ` Willy Tarreau
2008-05-14 4:55 ` Harald Dunkel
2008-05-14 5:46 ` Willy Tarreau
2008-05-14 7:34 ` Vegard Nossum
2008-05-14 17:05 ` Harald Dunkel
2008-05-14 17:17 ` Vegard Nossum
2008-05-14 17:35 ` Alan Cox
2008-05-18 17:56 ` Harald Dunkel
2008-05-18 17:51 ` Alan Cox
2008-05-20 19:01 ` Harald Dunkel
2008-05-20 19:12 ` david
2008-05-20 20:26 ` Harald Dunkel
2008-05-20 20:38 ` Willy Tarreau
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=19f34abd0806020316v4135935dxff04bcf663ebd4bf@mail.gmail.com \
--to=vegard.nossum@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=alan@redhat.com \
--cc=davidn@davidnewall.com \
--cc=harald.dunkel@t-online.de \
--cc=joe@skyrush.com \
--cc=linux-kernel@vger.kernel.org \
--cc=w@1wt.eu \
/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
Powered by JetHome