]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.6.2/kpageflags-fix-wrong-kpf_thp-on-non-huge-compound-pages.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.6.2 / kpageflags-fix-wrong-kpf_thp-on-non-huge-compound-pages.patch
1 From 7a71932d5676b7410ab64d149bad8bde6b0d8632 Mon Sep 17 00:00:00 2001
2 From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
3 Date: Mon, 8 Oct 2012 16:33:47 -0700
4 Subject: kpageflags: fix wrong KPF_THP on non-huge compound pages
5
6 From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
7
8 commit 7a71932d5676b7410ab64d149bad8bde6b0d8632 upstream.
9
10 KPF_THP can be set on non-huge compound pages (like slab pages or pages
11 allocated by drivers with __GFP_COMP) because PageTransCompound only
12 checks PG_head and PG_tail. Obviously this is a bug and breaks user space
13 applications which look for thp via /proc/kpageflags.
14
15 This patch rules out setting KPF_THP wrongly by additionally checking
16 PageLRU on the head pages.
17
18 Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
19 Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
20 Acked-by: David Rientjes <rientjes@google.com>
21 Reviewed-by: Fengguang Wu <fengguang.wu@intel.com>
22 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
23 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 fs/proc/page.c | 8 +++++++-
28 1 file changed, 7 insertions(+), 1 deletion(-)
29
30 --- a/fs/proc/page.c
31 +++ b/fs/proc/page.c
32 @@ -115,7 +115,13 @@ u64 stable_page_flags(struct page *page)
33 u |= 1 << KPF_COMPOUND_TAIL;
34 if (PageHuge(page))
35 u |= 1 << KPF_HUGE;
36 - else if (PageTransCompound(page))
37 + /*
38 + * PageTransCompound can be true for non-huge compound pages (slab
39 + * pages or pages allocated by drivers with __GFP_COMP) because it
40 + * just checks PG_head/PG_tail, so we need to check PageLRU to make
41 + * sure a given page is a thp, not a non-huge compound page.
42 + */
43 + else if (PageTransCompound(page) && PageLRU(compound_trans_head(page)))
44 u |= 1 << KPF_THP;
45
46 /*