Received: by 10.213.65.68 with SMTP id h4csp3864699imn; Tue, 10 Apr 2018 05:58:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Sbd/46aZECwWTyd9DAbOObpXX96QUAST3lRxWLSaJeuoBteRNGskiZcCoWZNwYBRwu0Px X-Received: by 10.99.117.79 with SMTP id f15mr209042pgn.263.1523365111944; Tue, 10 Apr 2018 05:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523365111; cv=none; d=google.com; s=arc-20160816; b=wpuSgtz/9HFAvX1gWK4s/nZUMbNAT9KAJEtLq8S6A2o/Q5+sjdiDyRsvEquBFRAcsu Pk/Nq2xAtDXlintqeprU9N2ZVff1Xy01kcTXxWorWwtbp+w0lhr9mZVKfKLel4LYvBww OWyIR2FVoGRW/GlSiZHb11N0sBtZE9x6rYFBqIeJf/Iej2QO2LONBUAhiVjYkH07Jkm3 vCmZWvWG5a50bvcIcXedc5XiIch5e3hPo3d6mW5nEGwFC5xV9KelptA/9xOXjqJkWOgV UAdTYE6MVJ9WiRlaeGQTrAgnV03JMsqbymbkWetj8Akvp8swwE6HhLZ85u7rD5AlrWUS bVrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=t0/MCIb67clDqBGWGlt8pU9+LYLE4MxtISJ/mGhj3jY=; b=Gb/R2CGS4iOxEVX7J073Hkz+F08vXSnmttAIKGAyoQGWfh/SsK7kNDTvfajbkIjYJM Jcl4ed0WfRP7VHgKWVyzVcGJnhJc5vGcmQCZ+SOBGp0nc+tplgVX7f4+vVa+iuUScOK0 Q0EePbQytqR8hfD9zSrY0ZASkRXvNhVqkUTkevHpQy4AiN9u2MAQwrzHSXzdhtCJHndX /hm/t4eqh/ZFgZa8FR3XyFe2EUz4DvY8zuOYyl9L1koES+EwAVstBk9QI8mLidueqZ4v vtJHJIXoR+AvcWljLRgpRvJBiF9oDk0Eqcko04A03I5lLdkMkXQg1wxOVzn+LbEBwj7m /eSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=geZavtue; 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 h10si1734272pgq.514.2018.04.10.05.57.55; Tue, 10 Apr 2018 05:58:31 -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=geZavtue; 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 S1753342AbeDJMyO (ORCPT + 99 others); Tue, 10 Apr 2018 08:54:14 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37224 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753187AbeDJMx7 (ORCPT ); Tue, 10 Apr 2018 08:53:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: 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=t0/MCIb67clDqBGWGlt8pU9+LYLE4MxtISJ/mGhj3jY=; b=geZavtue7GWgv3x8ramm/7uE2 ym6v6GXMVyJf5+x3WNsjEtHll1kFagQI62hos7DZ0isS+h6FNUdd7ZfqM/hlOrjKCPRWWEPJBZrIX VCfRj5IwoOBr4+v37AWcq0nradqcCaJ+Suu102E+s/6sCN1P+LVfLCvF810ruYvThF4Ge7Zkm8S9D RL8k3eAnlb0I5B0PXX3A0V8HoviLnmY7ZeFx2gI+U8YbYv5k8N2mXxx4NVAbNqh55W6OTCI1ImUJt D/kPk+olQaVYwng5qt1N/sYUEyBkfIbZEI+436FcmYZJFY7bfGBWDjWbcSUOZ7rs8kVTZSOB4HL43 V5/aDiTPQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f5smX-0004Bd-P2; Tue, 10 Apr 2018 12:53:53 +0000 From: Matthew Wilcox To: linux-mm@kvack.org Cc: Matthew Wilcox , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-kernel@vger.kernel.org, Jan Kara , Jeff Layton , Mel Gorman , stable@vger.kernel.org Subject: [PATCH 2/2] page cache: Mask off unwanted GFP flags Date: Tue, 10 Apr 2018 05:53:51 -0700 Message-Id: <20180410125351.15837-2-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180410125351.15837-1-willy@infradead.org> References: <20180410125351.15837-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox The page cache has used the mapping's GFP flags for allocating radix tree nodes for a long time. It took care to always mask off the __GFP_HIGHMEM flag, and masked off other flags in other paths, but the __GFP_ZERO flag was still able to sneak through. The __GFP_DMA and __GFP_DMA32 flags would also have been able to sneak through if they were ever used. Fix them all by using GFP_RECLAIM_MASK at the innermost location, and remove it from earlier in the callchain. Fixes: 19f99cee206c ("f2fs: add core inode operations") Reported-by: Minchan Kim Signed-off-by: Matthew Wilcox Cc: stable@vger.kernel.org --- mm/filemap.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index c2147682f4c3..1a4bfc5ed3dc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -785,7 +785,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) 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 *); @@ -841,7 +841,7 @@ static int __add_to_page_cache_locked(struct page *page, 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, false); @@ -1574,8 +1574,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, if (fgp_flags & FGP_ACCESSED) __SetPageReferenced(page); - err = add_to_page_cache_lru(page, mapping, offset, - gfp_mask & GFP_RECLAIM_MASK); + err = add_to_page_cache_lru(page, mapping, offset, gfp_mask); if (unlikely(err)) { put_page(page); page = NULL; @@ -2378,7 +2377,7 @@ static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask) if (!page) return -ENOMEM; - ret = add_to_page_cache_lru(page, mapping, offset, gfp_mask & GFP_KERNEL); + ret = add_to_page_cache_lru(page, mapping, offset, gfp_mask); if (ret == 0) ret = mapping->a_ops->readpage(file, page); else if (ret == -EEXIST) -- 2.16.3