From: "Jörn Engel" <joern@logfs.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Dave Jones <davej@redhat.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: pipe_release oops.
Date: Fri, 8 Mar 2013 13:26:49 -0500 [thread overview]
Message-ID: <20130308182648.GA25175@logfs.org> (raw)
In-Reply-To: <CA+55aFzwOnRnp2B09fKjt8hd9tOCv44H482z1QpCnYc2mywnpA@mail.gmail.com>
On Fri, 8 March 2013 10:30:01 -0800, Linus Torvalds wrote:
>
> Hmm. So I've been trying to figure this out, and I really don't see
> it. Every single pipe open routine *should* make sure that the inode
> has an inode->i_pipe field. So if the open() has succeeded and you
> have a valid file descriptor, the inode->i_pipe thing should be there.
Ok, here is a wild idea that is very likely wrong. But some
background first. I've had problems with process exit times and one
of the culprits turned out to be exit_files() where one device driver
went awol for several seconds. Fixing the device driver is hard, I
didn't see a good reason not to call exit_files() earlier and
exit_mm() was the other big offender, so the idea was to run both in
parallel and I applied the patch below.
As a result I've gotten a bunch of NULL pointer dereferences that only
happen in virtual machines, never on real hardware. For example
[<ffffffff81164bf8>] alloc_fd+0x38/0x130
[<ffffffff8114857e>] do_sys_open+0xee/0x1f0
[<ffffffff811486a1>] sys_open+0x21/0x30
[<ffffffff815bea29>] system_call_fastpath+0x16/0x1b
Now I can easily see how current->files being NULL will result in such
backtraces. I can also see how my patch moves the NULLing of
current->files a bit back in time. But I could never figure out how
my patch could have introduced a race that didn't exist before.
So the wild idea is that we have always had a very unlikely race with
current->files being NULL and trinity happens to hit it somehow.
Jörn
--
One of my most productive days was throwing away 1000 lines of code.
-- Ken Thompson.
diff --git a/kernel/exit.c b/kernel/exit.c
index f65345f9..5886799 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -4,6 +4,7 @@
* Copyright (C) 1991, 1992 Linus Torvalds
*/
+#include <linux/async.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
@@ -559,6 +560,11 @@ void exit_files(struct task_struct *tsk)
}
}
+static void exit_files_async(void *data, async_cookie_t cookie)
+{
+ exit_files(data);
+}
+
#ifdef CONFIG_MM_OWNER
/*
* A task is exiting. If it owned this mm, find a new owner for the mm.
@@ -905,6 +911,7 @@ static inline void check_stack_usage(void) {}
void do_exit(long code)
{
struct task_struct *tsk = current;
+ async_cookie_t files_cookie;
int group_dead;
profile_task_exit(tsk);
@@ -982,6 +989,7 @@ void do_exit(long code)
tsk->exit_code = code;
taskstats_exit(tsk, group_dead);
+ files_cookie = async_schedule(exit_files_async, tsk);
exit_mm(tsk);
if (group_dead)
@@ -990,7 +998,7 @@ void do_exit(long code)
exit_sem(tsk);
exit_shm(tsk);
- exit_files(tsk);
+ async_synchronize_cookie(files_cookie);
exit_fs(tsk);
exit_task_work(tsk);
check_stack_usage();
--
1.7.10.4
next prev parent reply other threads:[~2013-03-08 19:51 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 2:16 BUG_ON(nd->inode != parent->d_inode); Dave Jones
2013-03-07 15:30 ` BUG_ON(nd->inode->i_op->follow_link); Dave Jones
2013-03-07 17:30 ` BUG_ON(nd->inode->i_op->follow_link); Linus Torvalds
2013-03-07 19:35 ` BUG_ON(nd->inode->i_op->follow_link); Dave Jones
2013-03-07 20:33 ` BUG_ON(nd->inode->i_op->follow_link); Linus Torvalds
2013-03-07 21:38 ` ipc/testmsg GPF Dave Jones
2013-03-07 21:45 ` Linus Torvalds
2013-03-07 21:49 ` David Miller
2013-03-07 21:51 ` Linus Torvalds
2013-03-07 22:03 ` Dave Jones
2013-03-07 22:36 ` pipe_release oops Dave Jones
2013-03-07 23:14 ` fasync_remove_entry oops Dave Jones
2013-03-07 23:46 ` Linus Torvalds
2013-03-07 23:54 ` Dave Jones
2013-03-08 0:20 ` Dave Jones
2013-03-08 0:21 ` pipe_release oops Linus Torvalds
2013-03-08 14:53 ` Dave Jones
2013-03-08 18:30 ` Linus Torvalds
2013-03-08 18:26 ` Jörn Engel [this message]
2013-03-10 23:33 ` Al Viro
2013-03-12 19:09 ` Jörn Engel
2013-03-10 22:10 ` Al Viro
2013-03-11 0:35 ` Al Viro
2013-03-11 15:10 ` Linus Torvalds
2013-03-11 18:05 ` Al Viro
2013-03-12 13:06 ` Al Viro
2013-03-12 15:31 ` Linus Torvalds
2013-03-12 19:43 ` Al Viro
2013-03-12 19:56 ` Dave Jones
2013-03-12 20:09 ` Linus Torvalds
2013-03-12 20:51 ` Al Viro
2013-03-27 13:51 ` Yet another pipe related oops Dave Jones
2013-03-27 15:20 ` Al Viro
2013-03-27 16:33 ` Linus Torvalds
2013-03-27 16:53 ` Raymond Jennings
2013-03-27 17:45 ` Al Viro
2013-04-01 20:34 ` Al Viro
2013-04-01 21:00 ` Greg Kroah-Hartman
2013-04-01 21:21 ` Al Viro
2013-04-01 21:44 ` Greg Kroah-Hartman
2013-04-01 23:27 ` Al Viro
2013-04-02 0:22 ` Al Viro
2013-04-02 1:55 ` Greg Kroah-Hartman
2013-03-12 1:27 ` pipe_release oops Dave Jones
2013-03-09 0:27 ` ipc/testmsg GPF Peter Hurley
2013-03-09 0:32 ` Dave Jones
2013-03-11 18:26 ` Dave Jones
2013-03-11 19:03 ` Peter Hurley
2013-03-12 22:02 ` Andrew Morton
2013-03-12 22:33 ` Dave Jones
2013-03-15 21:21 ` Dave Jones
2013-03-25 16:37 ` Dave Jones
2013-03-25 18:28 ` Peter Hurley
2013-03-25 18:39 ` Dave Jones
2013-03-07 22:18 ` BUG_ON(nd->inode->i_op->follow_link); Dave Jones
2013-03-07 22:50 ` BUG_ON(nd->inode->i_op->follow_link); Linus Torvalds
2013-03-07 23:03 ` BUG_ON(nd->inode->i_op->follow_link); Dave Jones
2013-03-07 23:55 ` BUG_ON(nd->inode->i_op->follow_link); Linus Torvalds
2013-03-11 0:02 ` BUG_ON(nd->inode->i_op->follow_link); Al Viro
2013-03-10 23:04 ` BUG_ON(nd->inode->i_op->follow_link); Al Viro
2013-03-12 18:31 ` BUG_ON(nd->inode->i_op->follow_link); Linus Torvalds
2013-03-08 15:04 ` BUG_ON(nd->inode != parent->d_inode); Dave Jones
2013-03-08 18:51 ` Linus Torvalds
2013-03-08 19:18 ` Dave Jones
2013-03-08 19:20 ` Dave Jones
2013-03-08 19:36 ` Dave Jones
2013-03-08 19:47 ` Linus Torvalds
2013-03-08 21:04 ` Dave Jones
2013-03-08 22:41 ` Linus Torvalds
2013-03-08 23:07 ` Dave Jones
2013-03-08 23:14 ` Dave Jones
2013-03-08 23:20 ` Linus Torvalds
2013-03-08 23:28 ` Linus Torvalds
2013-03-08 23:34 ` Dave Jones
2013-03-08 23:47 ` Dave Jones
2013-03-08 23:51 ` Linus Torvalds
2013-03-08 23:30 ` Dave Jones
2013-03-08 23:45 ` Linus Torvalds
2013-03-08 23:55 ` Dave Jones
2013-03-09 0:02 ` Linus Torvalds
2013-03-09 0:19 ` Dave Jones
2013-03-09 0:29 ` Raymond Jennings
2013-03-09 0:36 ` Dave Jones
2013-03-09 1:18 ` Linus Torvalds
2013-03-09 2:03 ` Dave Jones
2013-03-09 2:08 ` Linus Torvalds
2013-03-09 2:26 ` Dave Jones
2013-03-09 2:56 ` Dave Jones
2013-03-09 2:57 ` Dave Jones
[not found] ` <CA+55aFxyOYXnzDoWr7Utr1QLjjMUCON5EGH3FMvGBHxnxMJmQQ@mail.gmail.com>
2013-03-09 3:25 ` Dave Jones
2013-03-09 3:38 ` Eric W. Biederman
2013-03-09 4:26 ` Dave Jones
2013-03-09 8:28 ` Eric W. Biederman
[not found] ` <CA+55aFweyfew3VU79ZQV4otJcWiF0=xKXxDtADXcccNxGaqMwA@mail.gmail.com>
2013-03-09 3:50 ` Dave Jones
2013-03-09 4:31 ` Linus Torvalds
2013-03-09 4:39 ` Dave Jones
2013-03-09 5:13 ` Sasha Levin
2013-03-09 5:16 ` Dave Jones
2013-03-09 3:27 ` Eric W. Biederman
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=20130308182648.GA25175@logfs.org \
--to=joern@logfs.org \
--cc=davej@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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