From: "Török Edwin" <edwintorok@gmail.com>
To: Dave Jones <davej@redhat.com>, Eric Sandeen <sandeen@redhat.com>,
"Theodore Ts'o" <tytso@mit.edu>,
Al Viro <viro@zeniv.linux.org.uk>,
Norbert Preining <preining@logic.at>
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
"Török Edwin" <edwintorok@gmail.com>
Subject: [PATCH] fix wrong iput on d_inode introduced by e6bc45d65d
Date: Thu, 16 Jun 2011 00:06:14 +0300 [thread overview]
Message-ID: <1308171974-7323-1-git-send-email-edwintorok@gmail.com> (raw)
In-Reply-To: <4DF868C8.3040903@gmail.com>
Git bisection shows that commit e6bc45d65df8599fdbae73be9cec4ceed274db53 causes
BUG_ONs under high I/O load:
kernel BUG at fs/inode.c:1368!
[ 2862.501007] Call Trace:
[ 2862.501007] [<ffffffff811691d8>] d_kill+0xf8/0x140
[ 2862.501007] [<ffffffff81169c19>] dput+0xc9/0x190
[ 2862.501007] [<ffffffff8115577f>] fput+0x15f/0x210
[ 2862.501007] [<ffffffff81152171>] filp_close+0x61/0x90
[ 2862.501007] [<ffffffff81152251>] sys_close+0xb1/0x110
[ 2862.501007] [<ffffffff814c14fb>] system_call_fastpath+0x16/0x1b
A reliable way to reproduce this bug is:
Login to KDE, run 'rsnapshot sync', and apt-get install openjdk-6-jdk,
and apt-get remove openjdk-6-jdk.
The buggy part of the patch is this:
struct inode *inode = NULL;
.....
- if (nd.last.name[nd.last.len])
- goto slashes;
inode = dentry->d_inode;
- if (inode)
- ihold(inode);
+ if (nd.last.name[nd.last.len] || !inode)
+ goto slashes;
+ ihold(inode)
...
if (inode)
iput(inode); /* truncate the inode here */
If nd.last.name[nd.last.len] is nonzero (and thus goto slashes branch is taken),
and dentry->d_inode is non-NULL, then this code now does an additional iput on
the inode, which is wrong.
Fix this by only setting the inode variable if nd.last.name[nd.last.len] is 0.
Reference: https://lkml.org/lkml/2011/6/15/50
Reported-by: Norbert Preining <preining@logic.at>
Reported-by: Török Edwin <edwintorok@gmail.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Török Edwin <edwintorok@gmail.com>
---
fs/namei.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index 9802345..6301963 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2713,8 +2713,10 @@ static long do_unlinkat(int dfd, const char __user *pathname)
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
/* Why not before? Because we want correct error value */
+ if (nd.last.name[nd.last.len])
+ goto slashes;
inode = dentry->d_inode;
- if (nd.last.name[nd.last.len] || !inode)
+ if (!inode)
goto slashes;
ihold(inode);
error = mnt_want_write(nd.path.mnt);
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-06-15 21:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-11 2:17 ext3 and btrfs various Oops and kernel BUGs Norbert Preining
2011-06-14 1:19 ` another ext3 kernel BUG Norbert Preining
2011-06-14 2:19 ` Eric Sandeen
2011-06-14 2:43 ` Norbert Preining
2011-06-14 3:21 ` Dave Jones
2011-06-14 3:32 ` Eric Sandeen
2011-06-14 4:03 ` Norbert Preining
2011-06-15 1:23 ` Norbert Preining
2011-06-15 8:09 ` Török Edwin
2011-06-15 21:06 ` Török Edwin [this message]
2011-06-16 5:51 ` Norbert Preining
2011-06-16 7:02 ` Török Edwin
2011-06-16 8:28 ` Norbert Preining
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=1308171974-7323-1-git-send-email-edwintorok@gmail.com \
--to=edwintorok@gmail.com \
--cc=davej@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=preining@logic.at \
--cc=sandeen@redhat.com \
--cc=tytso@mit.edu \
--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;
as well as URLs for NNTP newsgroup(s).