Passing "flags to clear in flags" is crufty.  Change things so we simply pass
the desired flags into do_brk.


---

 25-akpm/arch/sparc64/kernel/sys_sunos32.c |    2 -
 25-akpm/arch/x86_64/ia32/ia32_aout.c      |   14 ++++++++-----
 25-akpm/fs/binfmt_aout.c                  |   23 +++++++++++++--------
 25-akpm/fs/binfmt_elf.c                   |   32 +++++++++++++++---------------
 25-akpm/mm/mmap.c                         |    7 ++----
 25-akpm/mm/nommu.c                        |    2 -
 arch/s390/kernel/binfmt_elf32.c           |    0 
 arch/x86_64/ia32/ia32_binfmt.c            |    0 
 include/linux/mm.h                        |    0 
 9 files changed, 45 insertions(+), 35 deletions(-)

diff -puN arch/sparc64/kernel/sys_sunos32.c~bssprot-cleanup arch/sparc64/kernel/sys_sunos32.c
--- 25/arch/sparc64/kernel/sys_sunos32.c~bssprot-cleanup	2004-04-27 20:38:00.263778384 -0700
+++ 25-akpm/arch/sparc64/kernel/sys_sunos32.c	2004-04-27 20:38:00.280775800 -0700
@@ -173,7 +173,7 @@ asmlinkage int sunos_brk(u32 baddr)
 		goto out;
 	/* Ok, we have probably got enough memory - let it rip. */
 	current->mm->brk = brk;
-	do_brk(oldbrk, newbrk-oldbrk, 0);
+	do_brk(oldbrk, newbrk-oldbrk, VM_DATA_DEFAULT_FLAGS);
 	retval = 0;
 out:
 	up_write(&current->mm->mmap_sem);
diff -puN arch/s390/kernel/binfmt_elf32.c~bssprot-cleanup arch/s390/kernel/binfmt_elf32.c
diff -puN arch/x86_64/ia32/ia32_aout.c~bssprot-cleanup arch/x86_64/ia32/ia32_aout.c
--- 25/arch/x86_64/ia32/ia32_aout.c~bssprot-cleanup	2004-04-27 20:38:00.266777928 -0700
+++ 25-akpm/arch/x86_64/ia32/ia32_aout.c	2004-04-27 20:38:00.281775648 -0700
@@ -113,7 +113,7 @@ static void set_brk(unsigned long start,
 	end = PAGE_ALIGN(end);
 	if (end <= start)
 		return;
-	do_brk(start, end - start, 0);
+	do_brk(start, end - start, VM_DATA_DEFAULT_FLAGS);
 }
 
 #if CORE_DUMP
@@ -322,7 +322,8 @@ 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, 0);
+		error = do_brk(text_addr&PAGE_MASK, map_size,
+					VM_DATA_DEFAULT_FLAGS);
 		if (error != (text_addr & PAGE_MASK)) {
 			send_sig(SIGKILL, current, 0);
 			return error;
@@ -358,7 +359,8 @@ 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, 0);
+			do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data,
+					VM_DATA_DEFAULT_FLAGS);
 			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 +469,8 @@ static int load_aout_library(struct file
 		}
 #endif
 
-		do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss, 0);
+		do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss,
+				VM_DATA_DEFAULT_FLAGS);
 		
 		file->f_op->read(file, (char *)start_addr,
 			ex.a_text + ex.a_data, &pos);
@@ -491,7 +494,8 @@ 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, 0);
+		error = do_brk(start_addr + len, bss - len,
+					VM_DATA_DEFAULT_FLAGS);
 		retval = error;
 		if (error != start_addr + len)
 			goto out;
diff -puN arch/x86_64/ia32/ia32_binfmt.c~bssprot-cleanup arch/x86_64/ia32/ia32_binfmt.c
diff -puN fs/binfmt_aout.c~bssprot-cleanup fs/binfmt_aout.c
--- 25/fs/binfmt_aout.c~bssprot-cleanup	2004-04-27 20:38:00.271777168 -0700
+++ 25-akpm/fs/binfmt_aout.c	2004-04-27 20:38:00.282775496 -0700
@@ -43,13 +43,13 @@ static struct linux_binfmt aout_format =
 	.min_coredump	= PAGE_SIZE
 };
 
-static void set_brk(unsigned long start, unsigned long end, unsigned vm_inhibit)
+static void set_brk(unsigned long start, unsigned long end, unsigned flags)
 {
 	start = PAGE_ALIGN(start);
 	end = PAGE_ALIGN(end);
 	if (end <= start)
 		return;
-	do_brk(start, end - start, vm_inhibit);
+	do_brk(start, end - start, flags);
 }
 
 /*
@@ -317,10 +317,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, 0);
+		error = do_brk(N_TXTADDR(ex), ex.a_text, VM_DATA_DEFAULT_FLAGS);
 		bprm->file->f_op->read(bprm->file, (char *) N_TXTADDR(ex),
 			  ex.a_text, &pos);
-		error = do_brk(N_DATADDR(ex), ex.a_data, 0);
+		error = do_brk(N_DATADDR(ex), ex.a_data, VM_DATA_DEFAULT_FLAGS);
 		bprm->file->f_op->read(bprm->file, (char *) N_DATADDR(ex),
 			  ex.a_data, &pos);
 		goto beyond_if;
@@ -341,7 +341,8 @@ 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, 0);
+		error = do_brk(text_addr & PAGE_MASK, map_size,
+					VM_DATA_DEFAULT_FLAGS);
 		if (error != (text_addr & PAGE_MASK)) {
 			send_sig(SIGKILL, current, 0);
 			return error;
@@ -375,7 +376,8 @@ 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, 0);
+			do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data,
+						VM_DATA_DEFAULT_FLAGS);
 			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),
@@ -410,7 +412,8 @@ static int load_aout_binary(struct linux
 beyond_if:
 	set_binfmt(&aout_format);
 
-	set_brk(current->mm->start_brk, current->mm->brk, 0);
+	set_brk(current->mm->start_brk, current->mm->brk,
+			VM_DATA_DEFAULT_FLAGS);
 
 	retval = setup_arg_pages(bprm, EXSTACK_DEFAULT);
 	if (retval < 0) { 
@@ -476,7 +479,8 @@ static int load_aout_library(struct file
 			error_time = jiffies;
 		}
 
-		do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss, 0);
+		do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss,
+				VM_DATA_DEFAULT_FLAGS);
 		
 		file->f_op->read(file, (char *)start_addr,
 			ex.a_text + ex.a_data, &pos);
@@ -500,7 +504,8 @@ 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, 0);
+		error = do_brk(start_addr + len, bss - len,
+				VM_DATA_DEFAULT_FLAGS);
 		retval = error;
 		if (error != start_addr + len)
 			goto out;
diff -puN fs/binfmt_elf.c~bssprot-cleanup fs/binfmt_elf.c
--- 25/fs/binfmt_elf.c~bssprot-cleanup	2004-04-27 20:38:00.273776864 -0700
+++ 25-akpm/fs/binfmt_elf.c	2004-04-27 20:38:00.283775344 -0700
@@ -82,33 +82,33 @@ static struct linux_binfmt elf_format = 
 
 #define BAD_ADDR(x)	((unsigned long)(x) > TASK_SIZE)
 
-static inline unsigned long total_mapping_size(struct elf_phdr const *cmds, int nr)
+static inline unsigned long
+total_mapping_size(struct elf_phdr const *cmds, int nr)
 {
 	unsigned long lo = ~0UL, hi = 0UL;
 	int i;
 
-	for (i = 0; i < nr; i++)
+	for (i = 0; i < nr; i++) {
 		if (cmds[i].p_type == PT_LOAD) {
-			if (lo > cmds[i].p_vaddr) {
+			if (lo > cmds[i].p_vaddr)
 				lo = cmds[i].p_vaddr;
-			}
-			if (hi < (cmds[i].p_vaddr + cmds[i].p_memsz)) {
+			if (hi < (cmds[i].p_vaddr + cmds[i].p_memsz))
 				hi = cmds[i].p_vaddr + cmds[i].p_memsz;
-			}
 		}
+	}
 
-	if (hi==0UL)
+	if (hi == 0)
 		return 0;
 
 	return hi - ELF_PAGESTART(lo);
 }
 
-static inline int do_bss_pages(unsigned long start, unsigned long end, unsigned vm_inhibit)
+static int do_bss_pages(unsigned long start, unsigned long end, unsigned flags)
 {
 	start = ELF_PAGEALIGN(start);
 	end = ELF_PAGEALIGN(end);
 	if (end > start) {
-		unsigned long addr = do_brk(start, end - start, vm_inhibit);
+		unsigned long addr = do_brk(start, end - start, flags);
 		if (BAD_ADDR(addr))
 			return addr;
 	}
@@ -433,7 +433,8 @@ static unsigned long load_elf_interp(str
 	    		elf_bss += padzero(elf_bss);
 
 	    	error = do_bss_pages(elf_bss, load_addr + k,
-	    		calc_bss_inhibit(eppnt, elf_prot));
+	    			VM_DATA_DEFAULT_FLAGS &
+					~calc_bss_inhibit(eppnt, elf_prot));
 	    	if (error) {
 	    		goto out_close;
 	    	}
@@ -476,7 +477,7 @@ static unsigned long load_aout_interp(st
 		goto out;
 	}
 
-	do_brk(0, text_data, 0);
+	do_brk(0, text_data, VM_DATA_DEFAULT_FLAGS);
 	if (!interpreter->f_op || !interpreter->f_op->read)
 		goto out;
 	if (interpreter->f_op->read(interpreter, addr, text_data, &offset) < 0)
@@ -484,8 +485,8 @@ 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),
-		interp_ex->a_bss, 0);
+	do_brk(ELF_PAGESTART(text_data + ELF_MIN_ALIGN - 1), interp_ex->a_bss,
+				VM_DATA_DEFAULT_FLAGS);
 	elf_entry = interp_ex->a_entry;
 
 out:
@@ -822,7 +823,8 @@ static int load_elf_binary(struct linux_
 				place += padzero(place);
 
 			retval = do_bss_pages(place, load_bias + k,
-				calc_bss_inhibit(elf_ppnt, elf_prot));
+				VM_DATA_DEFAULT_FLAGS &
+					~calc_bss_inhibit(elf_ppnt, elf_prot));
 			if (retval) {
 				send_sig(SIGKILL, current, 0);
 				goto out_free_dentry;
@@ -1003,7 +1005,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, 0);
+		do_brk(len, bss - len, VM_DATA_DEFAULT_FLAGS);
 	error = 0;
 
 out_free_ph:
diff -puN include/linux/mm.h~bssprot-cleanup include/linux/mm.h
diff -puN mm/mmap.c~bssprot-cleanup mm/mmap.c
--- 25/mm/mmap.c~bssprot-cleanup	2004-04-27 20:38:00.275776560 -0700
+++ 25-akpm/mm/mmap.c	2004-04-27 20:38:00.285775040 -0700
@@ -132,7 +132,7 @@ asmlinkage unsigned long sys_brk(unsigne
 		goto out;
 
 	/* Ok, looks good - let it rip. */
-	if (do_brk(oldbrk, newbrk-oldbrk, 0) != oldbrk)
+	if (do_brk(oldbrk, newbrk-oldbrk, VM_DATA_DEFAULT_FLAGS) != oldbrk)
 		goto out;
 set_brk:
 	mm->brk = brk;
@@ -1378,7 +1378,7 @@ asmlinkage long sys_munmap(unsigned long
  *  anonymous maps.  eventually we may be able to do some
  *  brk-specific accounting here.
  */
-unsigned long do_brk(unsigned long addr, unsigned long len, unsigned vm_inhibit)
+unsigned long do_brk(unsigned long addr, unsigned long len, unsigned _flags)
 {
 	struct mm_struct * mm = current->mm;
 	struct vm_area_struct * vma, * prev;
@@ -1424,7 +1424,7 @@ unsigned long do_brk(unsigned long addr,
 	if (security_vm_enough_memory(len >> PAGE_SHIFT))
 		return -ENOMEM;
 
-	flags = (VM_DATA_DEFAULT_FLAGS &~ vm_inhibit) | VM_ACCOUNT | mm->def_flags;
+	flags = _flags | VM_ACCOUNT | mm->def_flags;
 
 	/* Can we just expand an old anonymous mapping? */
 	if (rb_parent && vma_merge(mm, prev, rb_parent, addr, addr + len,
@@ -1459,7 +1459,6 @@ out:
 	}
 	return addr;
 }
-
 EXPORT_SYMBOL(do_brk);
 
 /* Release all mmaps. */
diff -puN mm/nommu.c~bssprot-cleanup mm/nommu.c
--- 25/mm/nommu.c~bssprot-cleanup	2004-04-27 20:38:00.277776256 -0700
+++ 25-akpm/mm/nommu.c	2004-04-27 20:38:00.285775040 -0700
@@ -535,7 +535,7 @@ asmlinkage long sys_munmap(unsigned long
 	return ret;
 }
 
-unsigned long do_brk(unsigned long addr, unsigned long len, unsigned vm_inhibit)
+unsigned long do_brk(unsigned long addr, unsigned long len, unsigned flags)
 {
 	return -ENOMEM;
 }

_