Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp52432imu; Thu, 8 Nov 2018 14:37:53 -0800 (PST) X-Google-Smtp-Source: AJdET5fTkzYE4twIAk6PNKZjCTKQBD1g6nV0iEEb7zSmKFnnmVEJUH5FKjj/YrU9Qi4VdzRwAT9U X-Received: by 2002:a17:902:f08f:: with SMTP id go15mr2296069plb.332.1541716673868; Thu, 08 Nov 2018 14:37:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716673; cv=none; d=google.com; s=arc-20160816; b=aIfqBBWQNrucVCZv0IKYKsPiC/IjgZU0WEVvgkE0ycz/Hm79nZPqjna/JiWWOLctTT ePXGyBNJPolBiXdoB6Nw6U2K8wLnp8b7s/4TuFBYQDq0KmWlp/Np/5wt5OOH/1qDeQXO YAy/tJXu2eVN7MVTt7hFMvNBsaKR3UcWXH3WLHD9evslnnLTSAY+8DSKYsXQLEE8+Q0O D7zGaYu/La8w0c1weiyhPoSeCb4zc5q6vssyLxSa0uwLa4Th3Khk3/04uK/Vjdj4o1mv K2WypgcluZJJQ0uZTj9fgaocMInQfFC4hUXWXJycr/CEz4+b6is7bbuFTrjPv3IKn4fQ Wvpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qv5i+J7eC4P9vLwuKXx1EcfTxP2ZIYPWG54qZIbLiJ4=; b=x0sWMPYrjs6VG1HZu6scI9eXY90X5HV5IYSVs8ZSq7Bg9/JQa7yfNXLT3glrxLfT59 8YYKvrICt3oECphSYG9Lp5x38H1z6GSuRdY9TSgl/2gP5fpuqetbeDHcBfPZPEkr4TXU iS4VaRZFEndbQq7t+7kQ8A8bLl1E/BXlEbl+OScS36GTDCv9Q8bYLjTVQcDKM0RNj9MB FBh9pkylKUNJauaONGZ1SK3qIhQHjxNjenrtJ1JqE5ph7GrfMqRGiK48817Yx/4HT4DX d5PPl8sUu+c3W+9bnFn8n5O+DLJB9dseGtZu2hyJiCzRV1q9C1VELjAXCFaK/ELG2gLm dlHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jsP+O0pw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si5891209plt.225.2018.11.08.14.37.38; Thu, 08 Nov 2018 14:37:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jsP+O0pw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729912AbeKIHgm (ORCPT + 99 others); Fri, 9 Nov 2018 02:36:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:54222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728109AbeKIHgm (ORCPT ); Fri, 9 Nov 2018 02:36:42 -0500 Received: from localhost (unknown [208.72.13.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8FC7120818; Thu, 8 Nov 2018 21:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714353; bh=ZVkD4NL6p39YbzNObOjGWI16qDDrP1hq238hM2LgUrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jsP+O0pwYGo0zhU22LdWr/jONGcnf6+VGQ1QKQyTSHc+0LDLklGCUoXpQG9K0GGgd sjlvIBq82CKraShzQUV3rOeV9Te9waVtUF/FpRP7DrzjHzIIR75BaEVtbIqvTcrKdQ zpinB+iMMLhzZr7gAhVSPnaZnxUWoXKxcxrfoWz8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Ryabinin , Dmitry Vyukov , Konstantin Khlebnikov , Matthew Wilcox , Hugh Dickins , Ross Zwisler , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 027/114] radix-tree: fix radix_tree_iter_retry() for tagged iterators. Date: Thu, 8 Nov 2018 13:50:42 -0800 Message-Id: <20181108215101.574865326@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215059.051093652@linuxfoundation.org> References: <20181108215059.051093652@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 3cb9185c67304b2a7ea9be73e7d13df6fb2793a1 ] 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: 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 vfs_fsync fs/sync.c:209 do_fsync+0x42/0x70 fs/sync.c:219 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") Link: http://lkml.kernel.org/r/1468495196-10604-1-git-send-email-aryabinin@virtuozzo.com Signed-off-by: Andrey Ryabinin Reported-by: Dmitry Vyukov Acked-by: Konstantin Khlebnikov Cc: Matthew Wilcox Cc: Hugh Dickins Cc: Ross Zwisler Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- 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 5d5174b59802..673dee29a9b9 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h @@ -382,6 +382,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.17.1