Received: by 10.192.165.148 with SMTP id m20csp855959imm; Fri, 27 Apr 2018 08:35:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoktBCCYEFIABt34NfX7m8W+/VK34tS86nG+/Yq0JH98nlMv/Uy2SVqNUQp25yh/F87Jy9s X-Received: by 2002:a63:41c1:: with SMTP id o184-v6mr2503003pga.393.1524843315766; Fri, 27 Apr 2018 08:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524843315; cv=none; d=google.com; s=arc-20160816; b=s9ZX+n6nwRGjsTmx+w1H/LEWI36c/fTB3kB8DXtsQ2ReFleKQIloTuNyjc+mR8qnE3 W48ZCmGM4HnMwkhmHodNX+kLCdTg3k22i7hS/ZWF6tRb8oRVxNG7g6UDCLO2j2suWDhV gSOl976NGW8H6gJHHudlxELjBpLNA9oTmHofnf7qiW0i3wOPHX2x6ZsFWF4xdZw7uXXG INr9Br9JGnEN1aEHW4cSTa6NEhp1Y+lrUY1UCbI9k30DoATDgYeACYffx+4i0ojyHZTn PIkzlkHqEDutvPy3MjxBdaZqZmptuCzsxEXBPgCvEfWdrndlTmnXYhXMfdoj2CWw8QsB Ex/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=a3+wEcvVwfJelENA4l3Y5fMOuPYoyIkdo+9WrJ9lUT0=; b=lZ9SmaEoBkEz2wl9vfVwEJ/zQ920hxosudG+DCim9ZwuJgU+PpIrR462MoTBz24kV+ nYpZ/vbVRzlQqN9FzmbBQ/MYRzwNFrPjLL5Vz4IKtfAH34ZZIwC9Q713j9PF5LKidU/D 1sNIyRJ4AqqQ/jgU15QEjeCbkH8gCAcuEltrvv8ZGD5fc+fc3ZypCXFCqMFQnORRezYf ejHXhTCplne0z5m8FGfRrdxpeC9TrPAjP4cuzkeeqHp3P/a1aZxIhsz2b1sF5+xByanp 5SldUqCxGTq/slAxrCMlpUvA565ndCFeAgYyQNYsQ91ktTn5j1vZ57kX+Lm4pC4yG0nu t0/Q== ARC-Authentication-Results: i=1; mx.google.com; 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 w2-v6si1456834plz.226.2018.04.27.08.35.01; Fri, 27 Apr 2018 08:35:15 -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; 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 S932997AbeD0OAe (ORCPT + 99 others); Fri, 27 Apr 2018 10:00:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:47642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932989AbeD0OA2 (ORCPT ); Fri, 27 Apr 2018 10:00:28 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 4DE0821897; Fri, 27 Apr 2018 14:00:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DE0821897 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Wilcox , Chris Fries , Johannes Weiner , Michal Hocko , Jan Kara , Andrew Morton , Linus Torvalds , Harsh Shandilya Subject: [PATCH 3.18 07/24] mm/filemap.c: fix NULL pointer in page_cache_tree_insert() Date: Fri, 27 Apr 2018 15:57:42 +0200 Message-Id: <20180427135631.888933204@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135631.584839868@linuxfoundation.org> References: <20180427135631.584839868@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Matthew Wilcox commit abc1be13fd113ddef5e2d807a466286b864caed3 upstream. f2fs specifies the __GFP_ZERO flag for allocating some of its pages. Unfortunately, the page cache also uses the mapping's GFP flags for allocating radix tree nodes. It always masked off the __GFP_HIGHMEM flag, and masks off __GFP_ZERO in some paths, but not all. That causes radix tree nodes to be allocated with a NULL list_head, which causes backtraces like: __list_del_entry+0x30/0xd0 list_lru_del+0xac/0x1ac page_cache_tree_insert+0xd8/0x110 The __GFP_DMA and __GFP_DMA32 flags would also be able to sneak through if they are ever used. Fix them all by using GFP_RECLAIM_MASK at the innermost location, and remove it from earlier in the callchain. Link: http://lkml.kernel.org/r/20180411060320.14458-2-willy@infradead.org Fixes: 449dd6984d0e ("mm: keep page cache radix tree nodes in check") Signed-off-by: Matthew Wilcox Reported-by: Chris Fries Debugged-by: Minchan Kim Acked-by: Johannes Weiner Acked-by: Michal Hocko Reviewed-by: Jan Kara Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Harsh Shandilya Signed-off-by: Greg Kroah-Hartman --- mm/filemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/mm/filemap.c +++ b/mm/filemap.c @@ -468,7 +468,7 @@ int replace_page_cache_page(struct page VM_BUG_ON_PAGE(!PageLocked(new), new); VM_BUG_ON_PAGE(new->mapping, new); - error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM); + error = radix_tree_preload(gfp_mask & GFP_RECLAIM_MASK); if (!error) { struct address_space *mapping = old->mapping; void (*freepage)(struct page *); @@ -561,7 +561,7 @@ static int __add_to_page_cache_locked(st return error; } - error = radix_tree_maybe_preload(gfp_mask & ~__GFP_HIGHMEM); + error = radix_tree_maybe_preload(gfp_mask & GFP_RECLAIM_MASK); if (error) { if (!huge) mem_cgroup_cancel_charge(page, memcg);