linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tachino Nobuhiro <tachino@open.nm.fujitsu.co.jp>
To: linux-kernel@vger.kernel.org
Subject: [BUG-2.4.10] deadlock in do_truncate() and shmem_getpage()
Date: Tue, 02 Oct 2001 15:14:21 +0900	[thread overview]
Message-ID: <vghy1sci.wl@nisaaru.dvs.cs.fujitsu.co.jp> (raw)


Hello, 

I found a a deadlock bug in v2.4.10 due to invert locking order between
inode->i_truncate_sem and inode->i_sem.
Sequence is following.

do_truncate()
	down(&inode->i_sem);
	down_write(&inode->i_truncate_sem);


do_no_page()
	down_read(&inode->i_truncate_sem);

	shmem_nopage();
		shmem_getpage();
			down(&inode->i_sem);
	

Following patch works for me.


diff -r -u -N linux.org/fs/open.c linux/fs/open.c
--- linux.org/fs/open.c	Tue Oct  2 11:35:47 2001
+++ linux/fs/open.c	Tue Oct  2 11:45:33 2001
@@ -81,13 +81,13 @@
 	if (length < 0)
 		return -EINVAL;
 
-	down(&inode->i_sem);
 	down_write(&inode->i_truncate_sem);
+	down(&inode->i_sem);
 	newattrs.ia_size = length;
 	newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
 	error = notify_change(dentry, &newattrs);
-	up_write(&inode->i_truncate_sem);
 	up(&inode->i_sem);
+	up_write(&inode->i_truncate_sem);
 	return error;
 }
 

             reply	other threads:[~2001-10-02  6:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-02  6:14 Tachino Nobuhiro [this message]
2001-10-02  6:33 ` [BUG-2.4.10] deadlock in do_truncate() and shmem_getpage() Andrew Morton

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=vghy1sci.wl@nisaaru.dvs.cs.fujitsu.co.jp \
    --to=tachino@open.nm.fujitsu.co.jp \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).