From: ebiederm@xmission.com (Eric W. Biederman)
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
roland@redhat.com, linux-kernel@vger.kernel.org,
Pavel Emelyanov <xemul@openvz.org>,
Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Subject: Re: [PATCH] do_signal_stop: use signal_group_exit()
Date: Sun, 17 Feb 2008 21:11:14 -0700 [thread overview]
Message-ID: <m1skzq9a59.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20080217231019.GA83@tv-sign.ru> (Oleg Nesterov's message of "Mon, 18 Feb 2008 02:10:19 +0300")
Oleg Nesterov <oleg@tv-sign.ru> writes:
> On 02/16, Oleg Nesterov wrote:
>>
>> On 02/15, Andrew Morton wrote:
>> >
>> > ug. On about the fourth boot with the current -mm lineup I hit:
>> >
>> > : BUG: unable to handle kernel paging request at 0000000000200200
>> ^^^^^^^^^^^^^^^^
>> == LIST_POISON2
>>
>> > : IP: [<ffffffff802444f5>] free_pid+0x35/0x8e
>>
>> most probably == hlist_del_rcu(pid_chain)
>>
>> > : Call Trace:
>> > : [<ffffffff80237727>] ? release_task+0x152/0x2e5
>> > : [<ffffffff80237f81>] ? do_wait+0x6c7/0xa1c
>> > : [<ffffffff8022f4cc>] ? default_wake_function+0x0/0xe
>> > : [<ffffffff8023e670>] ? sys_rt_sigaction+0x7a/0x98
>> > : [<ffffffff80238360>] ? sys_wait4+0x8a/0xa1
>> > : [<ffffffff8020be4b>] ? system_call_after_swapgs+0x7b/0x80
>>
>> (Can't understand why there is no detach_pid() in this stack trace,
>> but it is the only possible caller of free_pid()).
That is just because of tail call optimization. There is no need
to return to detach_pid so we just jumped to free_pid.
>
>> So, detach_pid()->free_pid() hit an already unhashed pid. But this
>> is not possible?
>>
>> This means we already did detach_pid(), but in that case the previous
>> detach_pid() has set task->pids[].pid = NULL, and we should OOPS earlier,
>> somewhere at "if (!hlist_empty(&pid->tasks[tmp]))".
>
> Yes, this is not possible.
>
> But what possible is: we have the unbalanced put_pid(pid) which frees the
> live pid. The next alloc_pid() gets the same memory, and initializes all
> pid->tasks[] lists.
>
> Now, if that pid was used as PIDTYPE_PGID/PIDTYPE_SID, the next detach_pid()
> from this pgrp/sid sees that the pid is not used (all lists are hlist_empty),
> frees this pid again, and the bug manifests itself this way.
>
> tiocspgrp:
>
> put_pid(real_tty->pgrp);
> // ------ WINDOW ------
> real_tty->pgrp = get_pid(pgrp);
>
> When bash spawns the command, both parent and child do ioctl(TIOCSPGRP,child),
> and it is possible that both do put_pid() on the same parent's pid.
>
> Damn, when you know what the bug is, the test case is trivial:
>
> $ while true; do perl -e0; done
>
> The kernel crashes.
>
>>From 2.6.25-rc2-mm1.bz2 patch:
>>
>> - .ioctl = tty_ioctl,
>> + .unlocked_ioctl = tty_ioctl,
>
> and this is why this didn't happen before, I guess.
>
>> I'll try to think more about this, but I doubt very much I'll find the
>> reason :(
>
> Ohhh... 7 (!!!) hours of hacking + some vodka did the trick.
>
> (Kamalesh, I think you hit the same bug).
Thanks. Looks like we need to grab a lock there.
At a quick skim I think we need the tty lock.
Eric
next prev parent reply other threads:[~2008-02-18 4:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-15 18:02 Oleg Nesterov
2008-02-16 3:37 ` Andrew Morton
2008-02-16 14:02 ` Oleg Nesterov
2008-02-17 23:10 ` Oleg Nesterov
2008-02-18 4:11 ` Eric W. Biederman [this message]
2008-02-19 23:39 ` Valdis.Kletnieks
2008-02-20 16:14 ` [PATCH] (for -mm only) put_pid: make sure we don't free the live pid Oleg Nesterov
2008-02-20 16:18 ` tty && pid problems Oleg Nesterov
2008-02-20 16:19 ` Alan Cox
2008-02-22 1:39 ` Eric W. Biederman
2008-02-22 9:37 ` Alan Cox
2008-02-20 16:28 ` Oleg Nesterov
2008-02-20 19:00 ` Jiri Slaby
2008-02-20 2:32 ` [PATCH] do_signal_stop: use signal_group_exit() Eric W. Biederman
2008-02-16 15:09 ` [PATCH] free_pidmap: turn it into free_pidmap(struct upid *) Oleg Nesterov
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=m1skzq9a59.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=kamalesh@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--cc=roland@redhat.com \
--cc=xemul@openvz.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®