Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6322335imm; Mon, 23 Jul 2018 15:57:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeuQE7mj8SZwZJVaGCMrrf57/85kym5R/3iwPShjIqk3kqUHMJ4NJe7Z0u0/cjrp4f5r3df X-Received: by 2002:a63:ef10:: with SMTP id u16-v6mr14057623pgh.269.1532386627355; Mon, 23 Jul 2018 15:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532386627; cv=none; d=google.com; s=arc-20160816; b=d0rKFhUw9fDdW1cpKhWk6oMvTh4wd2Fl7TPP7oUfBBw0ZVVDjVkRXzcpKG72kJAQDy bGc6bNAC5zwYDgk9/EgKBX44iU0oSbpl98E5s3jCksUGTjl+LalEW6c1rw2eR+ZtpKIY AMdx9NLTYf9HCRmJNsxXaScNePBfSfqJF8ysVBzSyccqaTejGCFVok33jTabE2k20TNp tWf0apRwpOeGoTUCRye5P0c0bGSCqZRkDft7K+ugaqrx5O9nVH8ZHMex7B2oWoLs/Z7V ubc1C/S0xYVLWLGdjRz3jWy5hVZnk115YQ6Al6KAS41A9teWr9fjMcRsIGQpmrveEulk FhYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=CX16x5cyOJ8CtJJDMrQr5iF1k8tI5ZfPMhVdT30nfJw=; b=E9ZUQ/pxSuh2of1IWk2WLn7EJxs1UNULnBhTakPOy5JtkGP/EksedbiUkXGDMwREYo fX1aF74G/PFk1ixoxgoOxy/YwvR71yDIC2YqmqqBZLcSf4V1SeomsNvp2qQXj94dS43n N0h4+roEFgwQPz4hFqIhbqwy8fJV17Zj69UUaH5suJPQEHSC8VWNCFE9IgH7aXihSMRd XIti6zzstRiwJtzq+WVAJb8H+oyETpGFsszQX7Td+eR2X1Bz3kPH8KM2GIiVKGPaHyso yv2tJkMgPxixojf5zNAk+B4FQSspnjQM3heLz+FxYl4ENJPsiTrI7YCR5uWrOC9O3fj8 sxnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=VBwMbPrW; 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 31-v6si9003160plc.173.2018.07.23.15.56.51; Mon, 23 Jul 2018 15:57:07 -0700 (PDT) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=VBwMbPrW; 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 S2388245AbeGWX6Y (ORCPT + 99 others); Mon, 23 Jul 2018 19:58:24 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:43014 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388109AbeGWX6Y (ORCPT ); Mon, 23 Jul 2018 19:58:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CX16x5cyOJ8CtJJDMrQr5iF1k8tI5ZfPMhVdT30nfJw=; b=VBwMbPrWCjD27ped0yk8PFzb7 swaXSV9O4JlkDqORhMOhovpKX0Q7XCrVcHjYTcxmPRiYYHK52yJ66HLPH9pjeK/TfM/MkUBtyY09c HjU819kOD9OcJvWM2VF6vbxJRPAxSi2VcLU4msGyVlY3eGE+qrLIi038kF2TBImTT1Y/H7of2ByJg Zlxx9jWOv0Gg9Fgz3ErcdOWoZKEr4FdjBNvWTMetxva7E4xmgrjsiMGjclVF51MYwL6XfhYJ36QTE UP9WiUIYTT5o5qte3gD6pxDARbpDHvWnaRe6so5RvMVYhF1x2spT//kGvTuf1RrxERDGOnpWbO4+1 O4wZZ+usw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhjjC-00080D-Uh; Mon, 23 Jul 2018 22:54:54 +0000 Date: Mon, 23 Jul 2018 15:54:54 -0700 From: Matthew Wilcox To: Hugh Dickins Cc: syzbot , "Kirill A. Shutemov" , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com Subject: Re: kernel BUG at mm/shmem.c:LINE! Message-ID: <20180723225454.GC18236@bombadil.infradead.org> References: <000000000000d624c605705e9010@google.com> <20180709143610.GD2662@bombadil.infradead.org> <20180723140150.GA31843@bombadil.infradead.org> <20180723203628.GA18236@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 23, 2018 at 03:42:22PM -0700, Hugh Dickins wrote: > On Mon, 23 Jul 2018, Matthew Wilcox wrote: > > I figured out a fix and pushed it to the 'ida' branch in > > git://git.infradead.org/users/willy/linux-dax.git > > Great, thanks a lot for sorting that out so quickly. But I've cloned > the tree and don't see today's patch, so assume you've folded the fix > into an existing commit? If possible, please append the diff of today's > fix to this thread so that we can try it out. Or if that's difficult, > please at least tell which files were modified, then I can probably > work it out from the diff of those files against mmotm. Sure! It's just this: diff --git a/lib/xarray.c b/lib/xarray.c index 32a9c2a6a9e9..383c410997eb 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -660,6 +660,8 @@ void xas_create_range(struct xa_state *xas) unsigned char sibs = xas->xa_sibs; xas->xa_index |= ((sibs + 1) << shift) - 1; + if (!xas_top(xas->xa_node) && xas->xa_node->shift == xas->xa_shift) + xas->xa_offset |= sibs; xas->xa_shift = 0; xas->xa_sibs = 0; The only other things changed are the test suite, and removing an unnecessary change, so they can be ignored: diff --git a/lib/test_xarray.c b/lib/test_xarray.c index 8a67d4bb1788..ec06c3ca19e9 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -695,19 +695,20 @@ static noinline void check_move(struct xarray *xa) check_move_small(xa, (1UL << i) - 1); } -static noinline void check_create_range_1(struct xarray *xa, +static noinline void xa_store_many_order(struct xarray *xa, unsigned long index, unsigned order) { XA_STATE_ORDER(xas, xa, index, order); - unsigned int i; + unsigned int i = 0; do { xas_lock(&xas); + XA_BUG_ON(xa, xas_find_conflict(&xas)); xas_create_range(&xas); if (xas_error(&xas)) goto unlock; for (i = 0; i < (1U << order); i++) { - xas_store(&xas, xa + i); + XA_BUG_ON(xa, xas_store(&xas, xa_mk_value(index + i))); xas_next(&xas); } unlock: @@ -715,7 +716,29 @@ static noinline void check_create_range_1(struct xarray *xa, } while (xas_nomem(&xas, GFP_KERNEL)); XA_BUG_ON(xa, xas_error(&xas)); - xa_destroy(xa); +} + +static noinline void check_create_range_1(struct xarray *xa, + unsigned long index, unsigned order) +{ + unsigned long i; + + xa_store_many_order(xa, index, order); + for (i = index; i < index + (1UL << order); i++) + xa_erase_value(xa, i); + XA_BUG_ON(xa, !xa_empty(xa)); +} + +static noinline void check_create_range_2(struct xarray *xa, unsigned order) +{ + unsigned long i; + unsigned long nr = 1UL << order; + + for (i = 0; i < nr * nr; i += nr) + xa_store_many_order(xa, i, order); + for (i = 0; i < nr * nr; i++) + xa_erase_value(xa, i); + XA_BUG_ON(xa, !xa_empty(xa)); } static noinline void check_create_range(struct xarray *xa) @@ -729,6 +752,8 @@ static noinline void check_create_range(struct xarray *xa) check_create_range_1(xa, 2U << order, order); check_create_range_1(xa, 3U << order, order); check_create_range_1(xa, 1U << 24, order); + if (order < 10) + check_create_range_2(xa, order); } } diff --git a/mm/shmem.c b/mm/shmem.c index af2d7fa05af7..3ac507803787 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -589,8 +589,8 @@ static int shmem_add_to_page_cache(struct page *page, VM_BUG_ON(expected && PageTransHuge(page)); page_ref_add(page, nr); - page->index = index; page->mapping = mapping; + page->index = index; do { void *entry;