From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-f70.google.com (mail-vk0-f70.google.com [209.85.213.70]) by kanga.kvack.org (Postfix) with ESMTP id 4F3166B0005 for ; Thu, 14 Jul 2016 08:21:41 -0400 (EDT) Received: by mail-vk0-f70.google.com with SMTP id j65so70863427vkb.2 for ; Thu, 14 Jul 2016 05:21:41 -0700 (PDT) Received: from mail-qt0-x244.google.com (mail-qt0-x244.google.com. [2607:f8b0:400d:c0d::244]) by mx.google.com with ESMTPS id 71si425009uas.183.2016.07.14.05.21.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jul 2016 05:21:40 -0700 (PDT) Received: by mail-qt0-x244.google.com with SMTP id u25so2743498qtb.3 for ; Thu, 14 Jul 2016 05:21:40 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1468495196-10604-1-git-send-email-aryabinin@virtuozzo.com> References: <1468495196-10604-1-git-send-email-aryabinin@virtuozzo.com> From: Konstantin Khlebnikov Date: Thu, 14 Jul 2016 15:21:39 +0300 Message-ID: Subject: Re: [PATCH] radix-tree: fix radix_tree_iter_retry() for tagged iterators. Content-Type: text/plain; charset=UTF-8 Sender: owner-linux-mm@kvack.org List-ID: To: Andrey Ryabinin Cc: Andrew Morton , Jan Kara , ross.zwisler@linux.intel.com, "Kirill A. Shutemov" , "linux-mm@kvack.org" , Greg Thelen , Suleiman Souhlal , syzkaller , Kostya Serebryany , Alexander Potapenko , Sasha Levin , Linux Kernel Mailing List , Matthew Wilcox , Hugh Dickins , Stable ACK Originally retry could happen only at index 0 when first indirect node installed: in this case tags holds only 1 bit. Seems like now this happends at any index. On Thu, Jul 14, 2016 at 2:19 PM, Andrey Ryabinin wrote: > radix_tree_iter_retry() resets slot to NULL, but it doesn't reset tags. > Then NULL slot and non-zero iter.tags passed to radix_tree_next_slot() > leading to crash: > > RIP: [< inline >] radix_tree_next_slot include/linux/radix-tree.h:473 > [] find_get_pages_tag+0x334/0x930 mm/filemap.c:1452 > .... > Call Trace: > [] pagevec_lookup_tag+0x3a/0x80 mm/swap.c:960 > [] mpage_prepare_extent_to_map+0x321/0xa90 fs/ext4/inode.c:2516 > [] ext4_writepages+0x10be/0x2b20 fs/ext4/inode.c:2736 > [] do_writepages+0x97/0x100 mm/page-writeback.c:2364 > [] __filemap_fdatawrite_range+0x248/0x2e0 mm/filemap.c:300 > [] filemap_write_and_wait_range+0x121/0x1b0 mm/filemap.c:490 > [] ext4_sync_file+0x34d/0xdb0 fs/ext4/fsync.c:115 > [] vfs_fsync_range+0x10a/0x250 fs/sync.c:195 > [< inline >] vfs_fsync fs/sync.c:209 > [] do_fsync+0x42/0x70 fs/sync.c:219 > [< inline >] SYSC_fdatasync fs/sync.c:232 > [] SyS_fdatasync+0x19/0x20 fs/sync.c:230 > [] entry_SYSCALL_64_fastpath+0x23/0xc1 arch/x86/entry/entry_64.S:207 > > We must reset iterator's tags to bail out from radix_tree_next_slot() and > go to the slow-path in radix_tree_next_chunk(). > > Fixes: 46437f9a554f ("radix-tree: fix race in gang lookup") > Signed-off-by: Andrey Ryabinin > Reported-by: Dmitry Vyukov > Cc: Konstantin Khlebnikov > Cc: Matthew Wilcox > Cc: Hugh Dickins > Cc: > --- > include/linux/radix-tree.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h > index cb4b7e8..eca6f62 100644 > --- a/include/linux/radix-tree.h > +++ b/include/linux/radix-tree.h > @@ -407,6 +407,7 @@ static inline __must_check > void **radix_tree_iter_retry(struct radix_tree_iter *iter) > { > iter->next_index = iter->index; > + iter->tags = 0; > return NULL; > } > > -- > 2.7.3 > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org