Skip to content

Commit 227d53b

Browse files
kosakitorvalds
authored andcommitted
mm: __set_page_dirty uses spin_lock_irqsave instead of spin_lock_irq
To use spin_{un}lock_irq is dangerous if caller disabled interrupt. During aio buffer migration, we have a possibility to see the following call stack. aio_migratepage [disable interrupt] migrate_page_copy clear_page_dirty_for_io set_page_dirty __set_page_dirty_buffers __set_page_dirty spin_lock_irq This mean, current aio migration is a deadlockable. spin_lock_irqsave is a safer alternative and we should use it. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Reported-by: David Rientjes rientjes@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7bc35fd commit 227d53b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎fs/buffer.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,16 @@ EXPORT_SYMBOL(mark_buffer_dirty_inode);
654654
static void __set_page_dirty(struct page *page,
655655
struct address_space *mapping, int warn)
656656
{
657-
spin_lock_irq(&mapping->tree_lock);
657+
unsigned long flags;
658+
659+
spin_lock_irqsave(&mapping->tree_lock, flags);
658660
if (page->mapping) { /* Race with truncate? */
659661
WARN_ON_ONCE(warn && !PageUptodate(page));
660662
account_page_dirtied(page, mapping);
661663
radix_tree_tag_set(&mapping->page_tree,
662664
page_index(page), PAGECACHE_TAG_DIRTY);
663665
}
664-
spin_unlock_irq(&mapping->tree_lock);
666+
spin_unlock_irqrestore(&mapping->tree_lock, flags);
665667
__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
666668
}
667669

0 commit comments

Comments
 (0)