Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r1761 - genpatches-2.6/trunk/2.6.35
Date: Fri, 20 Aug 2010 20:32:16
Message-Id: 20100820203211.555242004C@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2010-08-20 20:32:11 +0000 (Fri, 20 Aug 2010)
3 New Revision: 1761
4
5 Added:
6 genpatches-2.6/trunk/2.6.35/1805_fix-user-visible-effects-of-stack-guard-page.patch
7 Modified:
8 genpatches-2.6/trunk/2.6.35/0000_README
9 Log:
10 Patch to make the stack guard page somewhat less visible to user space
11
12 Modified: genpatches-2.6/trunk/2.6.35/0000_README
13 ===================================================================
14 --- genpatches-2.6/trunk/2.6.35/0000_README 2010-08-20 20:17:25 UTC (rev 1760)
15 +++ genpatches-2.6/trunk/2.6.35/0000_README 2010-08-20 20:32:11 UTC (rev 1761)
16 @@ -51,6 +51,10 @@
17 From: https://bugzilla.kernel.org/show_bug.cgi?id=16588
18 Desc: Fix page table unmap for stack guard page properly
19
20 +Patch: 1805_fix-user-visible-effects-of-stack-guard-page.patch
21 +From: http://bugs.gentoo.org/show_bug.cgi?id=333477
22 +Desc: Make the stack guard page somewhat less visible to user space
23 +
24 Patch: 2600_support-eject-dell-studio-1555.patch
25 From: http://bugs.gentoo.org/show_bug.cgi?id=333379
26 Desc: Add support for eject key on Dell Studio 1555
27
28 Added: genpatches-2.6/trunk/2.6.35/1805_fix-user-visible-effects-of-stack-guard-page.patch
29 ===================================================================
30 --- genpatches-2.6/trunk/2.6.35/1805_fix-user-visible-effects-of-stack-guard-page.patch (rev 0)
31 +++ genpatches-2.6/trunk/2.6.35/1805_fix-user-visible-effects-of-stack-guard-page.patch 2010-08-20 20:32:11 UTC (rev 1761)
32 @@ -0,0 +1,85 @@
33 +From: Linus Torvalds <torvalds@××××××××××××××××.org>
34 +Date: Sun, 15 Aug 2010 18:35:52 +0000 (-0700)
35 +Subject: mm: fix up some user-visible effects of the stack guard page
36 +X-Git-Tag: v2.6.36-rc1~5
37 +X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=d7824370e26325c881b665350ce64fb0a4fde24a
38 +
39 +mm: fix up some user-visible effects of the stack guard page
40 +
41 +This commit makes the stack guard page somewhat less visible to user
42 +space. It does this by:
43 +
44 + - not showing the guard page in /proc/<pid>/maps
45 +
46 + It looks like lvm-tools will actually read /proc/self/maps to figure
47 + out where all its mappings are, and effectively do a specialized
48 + "mlockall()" in user space. By not showing the guard page as part of
49 + the mapping (by just adding PAGE_SIZE to the start for grows-up
50 + pages), lvm-tools ends up not being aware of it.
51 +
52 + - by also teaching the _real_ mlock() functionality not to try to lock
53 + the guard page.
54 +
55 + That would just expand the mapping down to create a new guard page,
56 + so there really is no point in trying to lock it in place.
57 +
58 +It would perhaps be nice to show the guard page specially in
59 +/proc/<pid>/maps (or at least mark grow-down segments some way), but
60 +let's not open ourselves up to more breakage by user space from programs
61 +that depends on the exact deails of the 'maps' file.
62 +
63 +Special thanks to Henrique de Moraes Holschuh for diving into lvm-tools
64 +source code to see what was going on with the whole new warning.
65 +
66 +Reported-and-tested-by: François Valenduc <francois.valenduc@××××××××××.be
67 +Reported-by: Henrique de Moraes Holschuh <hmh@×××××××.br>
68 +Cc: stable@××××××.org
69 +Signed-off-by: Linus Torvalds <torvalds@××××××××××××××××.org>
70 +---
71 +
72 +diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
73 +index aea1d3f..439fc1f 100644
74 +--- a/fs/proc/task_mmu.c
75 ++++ b/fs/proc/task_mmu.c
76 +@@ -210,6 +210,7 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
77 + int flags = vma->vm_flags;
78 + unsigned long ino = 0;
79 + unsigned long long pgoff = 0;
80 ++ unsigned long start;
81 + dev_t dev = 0;
82 + int len;
83 +
84 +@@ -220,8 +221,13 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
85 + pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
86 + }
87 +
88 ++ /* We don't show the stack guard page in /proc/maps */
89 ++ start = vma->vm_start;
90 ++ if (vma->vm_flags & VM_GROWSDOWN)
91 ++ start += PAGE_SIZE;
92 ++
93 + seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
94 +- vma->vm_start,
95 ++ start,
96 + vma->vm_end,
97 + flags & VM_READ ? 'r' : '-',
98 + flags & VM_WRITE ? 'w' : '-',
99 +diff --git a/mm/mlock.c b/mm/mlock.c
100 +index 3f82720..49e5e4c 100644
101 +--- a/mm/mlock.c
102 ++++ b/mm/mlock.c
103 +@@ -167,6 +167,14 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma,
104 + if (vma->vm_flags & VM_WRITE)
105 + gup_flags |= FOLL_WRITE;
106 +
107 ++ /* We don't try to access the guard page of a stack vma */
108 ++ if (vma->vm_flags & VM_GROWSDOWN) {
109 ++ if (start == vma->vm_start) {
110 ++ start += PAGE_SIZE;
111 ++ nr_pages--;
112 ++ }
113 ++ }
114 ++
115 + while (nr_pages > 0) {
116 + int i;
117 +