1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
diff -urp linux-2.6.7-uc0-r12/arch/mips/kernel/irixelf.c linux-2.6.7-uc0-r13/arch/mips/kernel/irixelf.c
--- linux-2.6.7-uc0-r12/arch/mips/kernel/irixelf.c 2004-06-16 06:20:26.000000000 +0100
+++ linux-2.6.7-uc0-r13/arch/mips/kernel/irixelf.c 2005-01-09 10:26:47.144058112 +0000
@@ -127,7 +127,7 @@ static void set_brk(unsigned long start,
end = PAGE_ALIGN(end);
if (end <= start)
return;
- do_brk(start, end - start);
+ do_brk_locked(start, end - start);
}
@@ -376,7 +376,7 @@ static unsigned int load_irix_interp(str
/* Map the last of the bss segment */
if (last_bss > len) {
- do_brk(len, (last_bss - len));
+ do_brk_locked(len, (last_bss - len));
}
kfree(elf_phdata);
@@ -564,7 +564,7 @@ void irix_map_prda_page (void)
unsigned long v;
struct prda *pp;
- v = do_brk (PRDA_ADDRESS, PAGE_SIZE);
+ v = do_brk_locked (PRDA_ADDRESS, PAGE_SIZE);
if (v < 0)
return;
@@ -856,7 +856,7 @@ static int load_irix_library(struct file
len = (elf_phdata->p_filesz + elf_phdata->p_vaddr+ 0xfff) & 0xfffff000;
bss = elf_phdata->p_memsz + elf_phdata->p_vaddr;
if (bss > len)
- do_brk(len, bss-len);
+ do_brk_locked(len, bss-len);
kfree(elf_phdata);
return 0;
}
diff -urp linux-2.6.7-uc0-r12/arch/sparc64/kernel/binfmt_aout32.c linux-2.6.7-uc0-r13/arch/sparc64/kernel/binfmt_aout32.c
--- linux-2.6.7-uc0-r12/arch/sparc64/kernel/binfmt_aout32.c 2004-06-16 06:19:23.000000000 +0100
+++ linux-2.6.7-uc0-r13/arch/sparc64/kernel/binfmt_aout32.c 2005-01-09 10:30:53.078670368 +0000
@@ -49,7 +49,7 @@ static void set_brk(unsigned long start,
end = PAGE_ALIGN(end);
if (end <= start)
return;
- do_brk(start, end - start);
+ do_brk_locked(start, end - start);
}
/*
@@ -245,10 +245,10 @@ static int load_aout32_binary(struct lin
if (N_MAGIC(ex) == NMAGIC) {
loff_t pos = fd_offset;
/* Fuck me plenty... */
- error = do_brk(N_TXTADDR(ex), ex.a_text);
+ error = do_brk_locked(N_TXTADDR(ex), ex.a_text);
bprm->file->f_op->read(bprm->file, (char *) N_TXTADDR(ex),
ex.a_text, &pos);
- error = do_brk(N_DATADDR(ex), ex.a_data);
+ error = do_brk_locked(N_DATADDR(ex), ex.a_data);
bprm->file->f_op->read(bprm->file, (char *) N_DATADDR(ex),
ex.a_data, &pos);
goto beyond_if;
@@ -256,7 +256,7 @@ static int load_aout32_binary(struct lin
if (N_MAGIC(ex) == OMAGIC) {
loff_t pos = fd_offset;
- do_brk(N_TXTADDR(ex) & PAGE_MASK,
+ do_brk_locked(N_TXTADDR(ex) & PAGE_MASK,
ex.a_text+ex.a_data + PAGE_SIZE - 1);
bprm->file->f_op->read(bprm->file, (char *) N_TXTADDR(ex),
ex.a_text+ex.a_data, &pos);
@@ -271,7 +271,7 @@ static int load_aout32_binary(struct lin
if (!bprm->file->f_op->mmap) {
loff_t pos = fd_offset;
- do_brk(0, ex.a_text+ex.a_data);
+ do_brk_locked(0, ex.a_text+ex.a_data);
bprm->file->f_op->read(bprm->file,(char *)N_TXTADDR(ex),
ex.a_text+ex.a_data, &pos);
goto beyond_if;
@@ -387,7 +387,7 @@ static int load_aout32_library(struct fi
len = PAGE_ALIGN(ex.a_text + ex.a_data);
bss = ex.a_text + ex.a_data + ex.a_bss;
if (bss > len) {
- error = do_brk(start_addr + len, bss - len);
+ error = do_brk_locked(start_addr + len, bss - len);
retval = error;
if (error != start_addr + len)
goto out;
diff -urp linux-2.6.7-uc0-r12/arch/x86_64/ia32/ia32_aout.c linux-2.6.7-uc0-r13/arch/x86_64/ia32/ia32_aout.c
--- linux-2.6.7-uc0-r12/arch/x86_64/ia32/ia32_aout.c 2004-06-16 06:20:26.000000000 +0100
+++ linux-2.6.7-uc0-r13/arch/x86_64/ia32/ia32_aout.c 2005-01-09 10:26:47.189051272 +0000
@@ -113,7 +113,7 @@ static void set_brk(unsigned long start,
end = PAGE_ALIGN(end);
if (end <= start)
return;
- do_brk(start, end - start);
+ do_brk_locked(start, end - start);
}
#if CORE_DUMP
@@ -322,7 +322,7 @@ static int load_aout_binary(struct linux
pos = 32;
map_size = ex.a_text+ex.a_data;
- error = do_brk(text_addr & PAGE_MASK, map_size);
+ error = do_brk_locked(text_addr & PAGE_MASK, map_size);
if (error != (text_addr & PAGE_MASK)) {
send_sig(SIGKILL, current, 0);
return error;
@@ -358,7 +358,7 @@ static int load_aout_binary(struct linux
if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) {
loff_t pos = fd_offset;
- do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
+ do_brk_locked(N_TXTADDR(ex), ex.a_text+ex.a_data);
bprm->file->f_op->read(bprm->file,(char *)N_TXTADDR(ex),
ex.a_text+ex.a_data, &pos);
flush_icache_range((unsigned long) N_TXTADDR(ex),
@@ -467,7 +467,7 @@ static int load_aout_library(struct file
}
#endif
- do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
+ do_brk_locked(start_addr, ex.a_text + ex.a_data + ex.a_bss);
file->f_op->read(file, (char *)start_addr,
ex.a_text + ex.a_data, &pos);
@@ -491,7 +491,7 @@ static int load_aout_library(struct file
len = PAGE_ALIGN(ex.a_text + ex.a_data);
bss = ex.a_text + ex.a_data + ex.a_bss;
if (bss > len) {
- error = do_brk(start_addr + len, bss - len);
+ error = do_brk_locked(start_addr + len, bss - len);
retval = error;
if (error != start_addr + len)
goto out;
diff -urp linux-2.6.7-uc0-r12/fs/binfmt_aout.c linux-2.6.7-uc0-r13/fs/binfmt_aout.c
--- linux-2.6.7-uc0-r12/fs/binfmt_aout.c 2005-01-09 10:22:05.000000000 +0000
+++ linux-2.6.7-uc0-r13/fs/binfmt_aout.c 2005-01-09 10:33:36.000000000 +0000
@@ -51,7 +51,7 @@ static int set_brk(unsigned long start,
start = PAGE_ALIGN(start);
end = PAGE_ALIGN(end);
if (end > start) {
- unsigned long addr = do_brk(start, end - start);
+ unsigned long addr = do_brk_locked(start, end - start);
if (BAD_ADDR(addr))
return addr;
}
@@ -323,10 +323,10 @@ static int load_aout_binary(struct linux
loff_t pos = fd_offset;
/* Fuck me plenty... */
/* <AOL></AOL> */
- error = do_brk(N_TXTADDR(ex), ex.a_text);
+ error = do_brk_locked(N_TXTADDR(ex), ex.a_text);
bprm->file->f_op->read(bprm->file, (char *) N_TXTADDR(ex),
ex.a_text, &pos);
- error = do_brk(N_DATADDR(ex), ex.a_data);
+ error = do_brk_locked(N_DATADDR(ex), ex.a_data);
bprm->file->f_op->read(bprm->file, (char *) N_DATADDR(ex),
ex.a_data, &pos);
goto beyond_if;
@@ -347,7 +347,7 @@ static int load_aout_binary(struct linux
map_size = ex.a_text+ex.a_data;
#endif
- error = do_brk(text_addr & PAGE_MASK, map_size);
+ error = do_brk_locked(text_addr & PAGE_MASK, map_size);
if (error != (text_addr & PAGE_MASK)) {
send_sig(SIGKILL, current, 0);
return error;
@@ -381,7 +381,7 @@ static int load_aout_binary(struct linux
if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) {
loff_t pos = fd_offset;
- do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
+ do_brk_locked(N_TXTADDR(ex), ex.a_text+ex.a_data);
bprm->file->f_op->read(bprm->file,(char *)N_TXTADDR(ex),
ex.a_text+ex.a_data, &pos);
flush_icache_range((unsigned long) N_TXTADDR(ex),
@@ -486,7 +486,7 @@ static int load_aout_library(struct file
error_time = jiffies;
}
- do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
+ do_brk_locked(start_addr, ex.a_text + ex.a_data + ex.a_bss);
file->f_op->read(file, (char *)start_addr,
ex.a_text + ex.a_data, &pos);
@@ -510,7 +510,7 @@ static int load_aout_library(struct file
len = PAGE_ALIGN(ex.a_text + ex.a_data);
bss = ex.a_text + ex.a_data + ex.a_bss;
if (bss > len) {
- error = do_brk(start_addr + len, bss - len);
+ error = do_brk_locked(start_addr + len, bss - len);
retval = error;
if (error != start_addr + len)
goto out;
diff -urp linux-2.6.7-uc0-r12/fs/binfmt_elf.c linux-2.6.7-uc0-r13/fs/binfmt_elf.c
--- linux-2.6.7-uc0-r12/fs/binfmt_elf.c 2005-01-09 10:22:04.000000000 +0000
+++ linux-2.6.7-uc0-r13/fs/binfmt_elf.c 2005-01-09 10:26:47.000000000 +0000
@@ -88,7 +88,7 @@ static int set_brk(unsigned long start,
start = ELF_PAGEALIGN(start);
end = ELF_PAGEALIGN(end);
if (end > start) {
- unsigned long addr = do_brk(start, end - start);
+ unsigned long addr = do_brk_locked(start, end - start);
if (BAD_ADDR(addr))
return addr;
}
@@ -405,7 +405,7 @@ static unsigned long load_elf_interp(str
/* Map the last of the bss segment */
if (last_bss > elf_bss) {
- error = do_brk(elf_bss, last_bss - elf_bss);
+ error = do_brk_locked(elf_bss, last_bss - elf_bss);
if (BAD_ADDR(error))
goto out_close;
}
@@ -445,7 +445,7 @@ static unsigned long load_aout_interp(st
goto out;
}
- do_brk(0, text_data);
+ do_brk_locked(0, text_data);
if (!interpreter->f_op || !interpreter->f_op->read)
goto out;
if (interpreter->f_op->read(interpreter, addr, text_data, &offset) < 0)
@@ -453,7 +453,7 @@ static unsigned long load_aout_interp(st
flush_icache_range((unsigned long)addr,
(unsigned long)addr + text_data);
- do_brk(ELF_PAGESTART(text_data + ELF_MIN_ALIGN - 1),
+ do_brk_locked(ELF_PAGESTART(text_data + ELF_MIN_ALIGN - 1),
interp_ex->a_bss);
elf_entry = interp_ex->a_entry;
@@ -1004,7 +1004,7 @@ static int load_elf_library(struct file
len = ELF_PAGESTART(elf_phdata->p_filesz + elf_phdata->p_vaddr + ELF_MIN_ALIGN - 1);
bss = elf_phdata->p_memsz + elf_phdata->p_vaddr;
if (bss > len)
- do_brk(len, bss - len);
+ do_brk_locked(len, bss - len);
error = 0;
out_free_ph:
diff -urp linux-2.6.7-uc0-r12/include/linux/mm.h linux-2.6.7-uc0-r13/include/linux/mm.h
--- linux-2.6.7-uc0-r12/include/linux/mm.h 2005-01-09 10:22:06.000000000 +0000
+++ linux-2.6.7-uc0-r13/include/linux/mm.h 2005-01-09 10:26:47.000000000 +0000
@@ -652,6 +652,7 @@ out:
extern int do_munmap(struct mm_struct *, unsigned long, size_t);
extern unsigned long do_brk(unsigned long, unsigned long);
+extern unsigned long do_brk_locked(unsigned long, unsigned long);
/* filemap.c */
extern unsigned long page_unuse(struct page *);
diff -urp linux-2.6.7-uc0-r12/mm/mmap.c linux-2.6.7-uc0-r13/mm/mmap.c
--- linux-2.6.7-uc0-r12/mm/mmap.c 2005-01-09 10:22:06.000000000 +0000
+++ linux-2.6.7-uc0-r13/mm/mmap.c 2005-01-09 10:26:47.000000000 +0000
@@ -1675,6 +1675,20 @@ out:
EXPORT_SYMBOL(do_brk);
+/* locking version of do_brk. */
+unsigned long do_brk_locked(unsigned long addr, unsigned long len)
+{
+ unsigned long ret;
+
+ down_write(¤t->mm->mmap_sem);
+ ret = do_brk(addr, len);
+ up_write(¤t->mm->mmap_sem);
+
+ return ret;
+}
+
+EXPORT_SYMBOL(do_brk_locked);
+
/* Release all mmaps. */
void exit_mmap(struct mm_struct *mm)
{
@@ -1804,3 +1818,4 @@ struct vm_area_struct *copy_vma(struct v
}
return new_vma;
}
+
diff -urp linux-2.6.7-uc0-r12/mm/nommu.c linux-2.6.7-uc0-r13/mm/nommu.c
--- linux-2.6.7-uc0-r12/mm/nommu.c 2005-01-09 10:22:01.000000000 +0000
+++ linux-2.6.7-uc0-r13/mm/nommu.c 2005-01-09 10:26:47.000000000 +0000
@@ -548,6 +548,11 @@ unsigned long do_brk(unsigned long addr,
return -ENOMEM;
}
+unsigned long do_brk_locked(unsigned long addr, unsigned long len)
+{
+ return -ENOMEM;
+}
+
struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr)
{
return NULL;
|