SOURCES: grsecurity-2.1.8-2.4.32-200601211647.patch - adapted for ...

zbyniu zbyniu at pld-linux.org
Mon Feb 6 21:14:36 CET 2006


Author: zbyniu                       Date: Mon Feb  6 20:14:36 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- adapted for PLD kernel

---- Files affected:
SOURCES:
   grsecurity-2.1.8-2.4.32-200601211647.patch (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/grsecurity-2.1.8-2.4.32-200601211647.patch
diff -u SOURCES/grsecurity-2.1.8-2.4.32-200601211647.patch:1.1 SOURCES/grsecurity-2.1.8-2.4.32-200601211647.patch:1.2
--- SOURCES/grsecurity-2.1.8-2.4.32-200601211647.patch:1.1	Mon Feb  6 21:13:20 2006
+++ SOURCES/grsecurity-2.1.8-2.4.32-200601211647.patch	Mon Feb  6 21:14:31 2006
@@ -2252,7 +2252,7 @@
 +	 */
 +	tss->esp0 = next->esp0;
 +
- 	if (prev->ioperm || next->ioperm) {
+ 	if (unlikely(prev->ioperm || next->ioperm)) {
  		if (next->ioperm) {
  			/*
 @@ -705,6 +730,11 @@ void fastcall __switch_to(struct task_st
@@ -6444,7 +6444,7 @@
  	}
 -
  	down_write(&current->mm->mmap_sem);
- 	error = do_mmap_pgoff(file, addr, len, prot, flags, off >> PAGE_SHIFT);
+ 	error = do_mmap_pgoff(current->mm, file, addr, len, prot, flags, off >> PAGE_SHIFT);
  	up_write(&current->mm->mmap_sem);
 @@ -72,6 +76,13 @@ unsigned long arch_get_unmapped_area(str
  	unsigned long end = TASK_SIZE;
@@ -6737,8 +6737,8 @@
  
  static struct file_operations mem_fops = {
 @@ -693,6 +743,11 @@ static int memory_open(struct inode * in
- 		case 9:
- 			filp->f_op = &urandom_fops;
+ 		case 10:
+ 			filp->f_op = &anon_file_operations;
  			break;
 +#ifdef CONFIG_GRKERNSEC
 +		case 13:
@@ -6748,12 +6748,10 @@
  		default:
  			return -ENXIO;
  	}
-@@ -719,7 +774,10 @@ void __init memory_devfs_register (void)
- 	{5, "zero",    S_IRUGO | S_IWUGO,           &zero_fops},
- 	{7, "full",    S_IRUGO | S_IWUGO,           &full_fops},
+@@ -719,6 +774,9 @@ void __init memory_devfs_register (void)
  	{8, "random",  S_IRUGO | S_IWUSR,           &random_fops},
--	{9, "urandom", S_IRUGO | S_IWUSR,           &urandom_fops}
-+	{9, "urandom", S_IRUGO | S_IWUSR,           &urandom_fops},
+	{9, "urandom", S_IRUGO | S_IWUSR,           &urandom_fops},
+ 	{10, "anon", S_IRUGO | S_IWUSR,             &anon_file_operations},
 +#ifdef CONFIG_GRKERNSEC
 +	{13,"grsec",   S_IRUSR | S_IWUGO,	    &grsec_fops}
 +#endif
@@ -7152,7 +7150,7 @@
 +
 +#ifdef CONFIG_GRKERNSEC_PAX_RANDEXEC
 +		if (current->mm->pax_flags & MF_PAX_RANDEXEC)
-+			retval = __do_mmap_pgoff(NULL, ELF_PAGEALIGN(start + current->mm->delta_exec), 0UL, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_MIRROR, start);
++			retval = __do_mmap_pgoff(current->mm, NULL, ELF_PAGEALIGN(start + current->mm->delta_exec), 0UL, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_MIRROR, start);
 +		if (BAD_ADDR(retval))
 +			goto out;
 +#endif
@@ -7510,7 +7508,7 @@
 +					goto out_free_dentry;
 +				}
 +				down_write(&current->mm->mmap_sem);
-+				error = __do_mmap_pgoff(bprm->file, addr, len, elf_prot, elf_flags, (elf_ppnt->p_offset - ELF_PAGEOFFSET(elf_ppnt->p_vaddr)) >> PAGE_SHIFT);
++				error = __do_mmap_pgoff(current->mm, bprm->file, addr, len, elf_prot, elf_flags, (elf_ppnt->p_offset - ELF_PAGEOFFSET(elf_ppnt->p_vaddr)) >> PAGE_SHIFT);
 +				up_write(&current->mm->mmap_sem);
 +			}
 +#endif
@@ -7535,20 +7533,20 @@
 +
 +#ifdef CONFIG_GRKERNSEC_PAX_PAGEEXEC
 +			if (current->mm->pax_flags & MF_PAX_PAGEEXEC)
-+				load_addr_random = __do_mmap_pgoff(NULL, ELF_PAGESTART(load_bias_random + vaddr), 0UL, elf_prot, elf_flags | MAP_MIRROR, error);
++				load_addr_random = __do_mmap_pgoff(current->mm, NULL, ELF_PAGESTART(load_bias_random + vaddr), 0UL, elf_prot, elf_flags | MAP_MIRROR, error);
 +#endif
 +
 +#ifdef CONFIG_GRKERNSEC_PAX_SEGMEXEC
 +			if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
 +				if (elf_prot & PROT_EXEC) {
-+					load_addr_random = __do_mmap_pgoff(NULL, ELF_PAGESTART(load_bias_random + vaddr), elf_ppnt->p_memsz + ELF_PAGEOFFSET(elf_ppnt->p_vaddr), PROT_NONE, MAP_PRIVATE | MAP_FIXED, 0UL);
++					load_addr_random = __do_mmap_pgoff(current->mm, NULL, ELF_PAGESTART(load_bias_random + vaddr), elf_ppnt->p_memsz + ELF_PAGEOFFSET(elf_ppnt->p_vaddr), PROT_NONE, MAP_PRIVATE | MAP_FIXED, 0UL);
 +					if (!BAD_ADDR(load_addr_random)) {
-+						load_addr_random = __do_mmap_pgoff(NULL, ELF_PAGESTART(load_bias_random + vaddr + SEGMEXEC_TASK_SIZE), 0UL, elf_prot, elf_flags | MAP_MIRROR, error);
++						load_addr_random = __do_mmap_pgoff(current->mm, NULL, ELF_PAGESTART(load_bias_random + vaddr + SEGMEXEC_TASK_SIZE), 0UL, elf_prot, elf_flags | MAP_MIRROR, error);
 +						if (!BAD_ADDR(load_addr_random))
 +							load_addr_random -= SEGMEXEC_TASK_SIZE;
 +					}
 +				} else
-+					load_addr_random = __do_mmap_pgoff(NULL, ELF_PAGESTART(load_bias_random + vaddr), 0UL, elf_prot, elf_flags | MAP_MIRROR, error);
++					load_addr_random = __do_mmap_pgoff(current->mm, NULL, ELF_PAGESTART(load_bias_random + vaddr), 0UL, elf_prot, elf_flags | MAP_MIRROR, error);
 +			}
 +#endif
 +
@@ -8254,7 +8252,7 @@
  		goto ok;
  	}
  
-@@ -1053,8 +1080,22 @@ do_last:
+@@ -1053,9 +1080,23 @@ do_last:
  
  	/* Negative dentry, just create the file */
  	if (!dentry->d_inode) {
@@ -8269,15 +8267,16 @@
 +			goto exit_dput;
 +		}
 +
- 		error = vfs_create(dir->d_inode, dentry,
- 				   mode & ~current->fs->umask);
+ 		if (!IS_POSIXACL(dir->d_inode))
+ 			mode &= ~current->fs->umask;
+ 		error = vfs_create(dir->d_inode, dentry, mode);
 +		if (!error)
 +			gr_handle_create(dentry, nd->mnt);
 +
  		up(&dir->d_inode->i_sem);
  		dput(nd->dentry);
  		nd->dentry = dentry;
-@@ -1063,12 +1104,34 @@ do_last:
+@@ -1064,12 +1105,34 @@ do_last:
  		/* Don't check for write permission, don't truncate */
  		acc_mode = 0;
  		flag &= ~O_TRUNC;
@@ -8312,7 +8311,7 @@
  	up(&dir->d_inode->i_sem);
  
  	error = -EEXIST;
-@@ -1158,7 +1221,7 @@ ok:
+@@ -1159,7 +1222,7 @@ ok:
  		if (!error) {
  			DQUOT_INIT(inode);
  			
@@ -8321,7 +8320,7 @@
  		}
  		put_write_access(inode);
  		if (error)
-@@ -1189,6 +1252,13 @@ do_link:
+@@ -1190,6 +1253,13 @@ do_link:
  	 * stored in nd->last.name and we will have to putname() it when we
  	 * are done. Procfs-like symlinks just set LAST_BIND.
  	 */
@@ -8335,9 +8334,9 @@
  	UPDATE_ATIME(dentry->d_inode);
  	mnt = mntget(nd->mnt);
  	error = dentry->d_inode->i_op->follow_link(dentry, nd);
-@@ -1289,6 +1359,19 @@ asmlinkage long sys_mknod(const char * f
- 
- 	mode &= ~current->fs->umask;
+@@ -1291,6 +1361,19 @@ asmlinkage long sys_mknod(const char * f
+ 	if (!IS_POSIXACL(nd.dentry->d_inode))
+ 		mode &= ~current->fs->umask;
  	if (!IS_ERR(dentry)) {
 +		if (gr_handle_chroot_mknod(dentry, nd.mnt, mode) ||
 +		    gr_handle_chroot_chmod(dentry, nd.mnt, mode)) {
@@ -8355,7 +8354,7 @@
  		switch (mode & S_IFMT) {
  		case 0: case S_IFREG:
  			error = vfs_create(nd.dentry->d_inode,dentry,mode);
-@@ -1302,8 +1385,13 @@ asmlinkage long sys_mknod(const char * f
+@@ -1304,8 +1387,13 @@ asmlinkage long sys_mknod(const char * f
  		default:
  			error = -EINVAL;
  		}
@@ -8369,26 +8368,25 @@
  	up(&nd.dentry->d_inode->i_sem);
  	path_release(&nd);
  out:
-@@ -1355,8 +1443,17 @@ asmlinkage long sys_mkdir(const char * p
- 		dentry = lookup_create(&nd, 1);
- 		error = PTR_ERR(dentry);
+@@ -1359,7 +1447,16 @@ asmlinkage long sys_mkdir(const char * p
  		if (!IS_ERR(dentry)) {
--			error = vfs_mkdir(nd.dentry->d_inode, dentry,
+ 			if (!IS_POSIXACL(nd.dentry->d_inode))
+ 				mode &= ~current->fs->umask;
+-			error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
 +			error = 0;
 +
 +			if (!gr_acl_handle_mkdir(dentry, nd.dentry, nd.mnt))
 +				error = -EACCES;
 +
 +			if(!error)
-+				error = vfs_mkdir(nd.dentry->d_inode, dentry,
- 					  mode & ~current->fs->umask);
++				error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
 +			if(!error)
 +				gr_handle_create(dentry, nd.mnt);
-+			
++
  			dput(dentry);
  		}
  		up(&nd.dentry->d_inode->i_sem);
-@@ -1440,6 +1537,8 @@ asmlinkage long sys_rmdir(const char * p
+@@ -1443,6 +1540,8 @@ asmlinkage long sys_rmdir(const char * p
  	char * name;
  	struct dentry *dentry;
  	struct nameidata nd;
@@ -8397,7 +8395,7 @@
  
  	name = getname(pathname);
  	if(IS_ERR(name))
-@@ -1464,7 +1563,22 @@ asmlinkage long sys_rmdir(const char * p
+@@ -1467,7 +1566,22 @@ asmlinkage long sys_rmdir(const char * p
  	dentry = lookup_hash(&nd.last, nd.dentry);
  	error = PTR_ERR(dentry);
  	if (!IS_ERR(dentry)) {
@@ -8421,7 +8419,7 @@
  		dput(dentry);
  	}
  	up(&nd.dentry->d_inode->i_sem);
-@@ -1508,6 +1622,8 @@ asmlinkage long sys_unlink(const char * 
+@@ -1512,6 +1626,8 @@ asmlinkage long sys_unlink(const char * 
  	char * name;
  	struct dentry *dentry;
  	struct nameidata nd;
@@ -8430,7 +8428,7 @@
  
  	name = getname(pathname);
  	if(IS_ERR(name))
-@@ -1526,7 +1642,21 @@ asmlinkage long sys_unlink(const char * 
+@@ -1530,7 +1646,21 @@ asmlinkage long sys_unlink(const char * 
  		/* Why not before? Because we want correct error value */
  		if (nd.last.name[nd.last.len])
  			goto slashes;
@@ -8453,7 +8451,7 @@
  	exit2:
  		dput(dentry);
  	}
-@@ -1590,7 +1720,15 @@ asmlinkage long sys_symlink(const char *
+@@ -1594,7 +1724,15 @@ asmlinkage long sys_symlink(const char *
  		dentry = lookup_create(&nd, 0);
  		error = PTR_ERR(dentry);
  		if (!IS_ERR(dentry)) {
@@ -8470,7 +8468,7 @@
  			dput(dentry);
  		}
  		up(&nd.dentry->d_inode->i_sem);
-@@ -1674,7 +1812,27 @@ asmlinkage long sys_link(const char * ol
+@@ -1678,7 +1816,27 @@ asmlinkage long sys_link(const char * ol
  		new_dentry = lookup_create(&nd, 0);
  		error = PTR_ERR(new_dentry);
  		if (!IS_ERR(new_dentry)) {
@@ -8499,7 +8497,7 @@
  			dput(new_dentry);
  		}
  		up(&nd.dentry->d_inode->i_sem);
-@@ -1905,10 +2063,15 @@ static inline int do_rename(const char *
+@@ -1914,10 +2072,15 @@ static inline int do_rename(const char *
  	if (IS_ERR(new_dentry))
  		goto exit4;
  
@@ -14905,7 +14903,7 @@
 +gr_handle_chroot_setpriority(const struct task_struct *p, const int niceval)
 +{
 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
-+	if (grsec_enable_chroot_nice && (niceval < p->nice)
++	if (grsec_enable_chroot_nice && (niceval < task_nice(p))
 +			&& proc_is_chrooted(current)) {
 +		gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, p->pid);
 +		return -EACCES;
@@ -17515,9 +17513,9 @@
  
 +void pax_switch_segments(struct task_struct *);
 +
- #define prepare_to_switch()	do { } while(0)
  #define switch_to(prev,next,last) do {					\
  	asm volatile("pushl %%esi\n\t"					\
+ 		     "pushl %%edi\n\t"					\
 diff -urNp linux-2.4.32/include/asm-ia64/elf.h linux-2.4.32/include/asm-ia64/elf.h
 --- linux-2.4.32/include/asm-ia64/elf.h	2003-11-28 13:26:21.000000000 -0500
 +++ linux-2.4.32/include/asm-ia64/elf.h	2006-01-21 16:36:59.524245200 -0500
@@ -19444,7 +19442,7 @@
  	unsigned long len, unsigned long prot,
  	unsigned long flag, unsigned long pgoff);
  
-+extern unsigned long __do_mmap_pgoff(struct file *file, unsigned long addr,
++extern unsigned long __do_mmap_pgoff(struct mm_struct *mm, struct file *file, unsigned long addr,
 +	unsigned long len, unsigned long prot,
 +	unsigned long flag, unsigned long pgoff);
 +
@@ -19679,7 +19677,7 @@
  
 +#include <asm/current.h>
 +
- static inline struct task_struct *find_task_by_pid(int pid)
+ static inline task_t *find_task_by_pid(int pid)
  {
  	struct task_struct *p, **htable = &pidhash[pid_hashfn(pid)];
 @@ -557,6 +620,8 @@ static inline struct task_struct *find_t
@@ -19996,15 +19994,60 @@
 diff -urNp linux-2.4.32/kernel/exit.c linux-2.4.32/kernel/exit.c
 --- linux-2.4.32/kernel/exit.c	2002-11-28 18:53:15.000000000 -0500
 +++ linux-2.4.32/kernel/exit.c	2006-01-21 16:36:59.895188808 -0500
-@@ -16,6 +16,7 @@
+@@ -16,6 +16,12 @@
  #ifdef CONFIG_BSD_PROCESS_ACCT
  #include <linux/acct.h>
  #endif
++#include <linux/file.h>
 +#include <linux/grsecurity.h>
++
++#ifdef CONFIG_GRKERNSEC
++extern rwlock_t grsec_exec_file_lock;
++#endif
  
  #include <asm/uaccess.h>
  #include <asm/pgtable.h>
-@@ -439,10 +440,16 @@ fake_volatile:
+@@ -139,12 +145,23 @@ void reparent_to_init(void)
+ {
+ 	write_lock_irq(&tasklist_lock);
+ 
++#ifdef CONFIG_GRKERNSEC
++	write_lock(&grsec_exec_file_lock);
++	if (current->exec_file) {
++		fput(current->exec_file);
++		current->exec_file = NULL;
++	}
++	write_unlock(&grsec_exec_file_lock);
++#endif
++
+ 	/* Reparent to init */
+ 	REMOVE_LINKS(current);
+ 	current->p_pptr = child_reaper;
+ 	current->p_opptr = child_reaper;
+ 	SET_LINKS(current);
+ 
++	gr_set_kernel_label(current);
++
+ 	/* Set the exit signal to SIGCHLD so we signal init on exit */
+ 	current->exit_signal = SIGCHLD;
+ 
+@@ -173,6 +190,15 @@ void daemonize(void)
+ {
+ 	struct fs_struct *fs;
+ 
++#ifdef CONFIG_GRKERNSEC
++	write_lock(&grsec_exec_file_lock);
++	if (current->exec_file) {
++		fput(current->exec_file);
++		current->exec_file = NULL;
++	}
++	write_unlock(&grsec_exec_file_lock);
++#endif
++	gr_set_kernel_label(current);
+ 
+ 	/*
+ 	 * If we were started as result of loading a module, close all of the
+@@ -485,10 +511,16 @@ fake_volatile:
  #ifdef CONFIG_BSD_PROCESS_ACCT
  	acct_process(code);
  #endif
@@ -20179,9 +20222,9 @@
 --- linux-2.4.32/kernel/printk.c	2004-11-17 06:54:22.000000000 -0500
 +++ linux-2.4.32/kernel/printk.c	2006-01-21 16:36:59.941181816 -0500
 @@ -26,6 +26,7 @@
- #include <linux/module.h>
  #include <linux/interrupt.h>			/* For in_interrupt() */
  #include <linux/config.h>
+ #include <linux/delay.h>
 +#include <linux/grsecurity.h>
  
  #include <asm/uaccess.h>
@@ -20201,27 +20244,15 @@
 diff -urNp linux-2.4.32/kernel/sched.c linux-2.4.32/kernel/sched.c
 --- linux-2.4.32/kernel/sched.c	2004-11-17 06:54:22.000000000 -0500
 +++ linux-2.4.32/kernel/sched.c	2006-01-21 16:36:59.949180600 -0500
-@@ -22,6 +22,7 @@
- #include <linux/config.h>
- #include <linux/mm.h>
- #include <linux/init.h>
-+#include <linux/file.h>
- #include <linux/smp_lock.h>
- #include <linux/nmi.h>
- #include <linux/interrupt.h>
-@@ -29,6 +30,11 @@
+@@ -25,6 +25,7 @@
+ #include <asm/mmu_context.h>
+ #include <linux/kernel_stat.h>
  #include <linux/completion.h>
- #include <linux/prefetch.h>
- #include <linux/compiler.h>
 +#include <linux/grsecurity.h>
-+
-+#ifdef CONFIG_GRKERNSEC
-+extern rwlock_t grsec_exec_file_lock;
-+#endif
  
- #include <asm/uaccess.h>
- #include <asm/mmu_context.h>
-@@ -910,6 +916,9 @@ asmlinkage long sys_nice(int increment)
+ /*
+  * Convert user-nice values [ -20 ... 0 ... 19 ]
+@@ -1192,6 +1193,9 @@ asmlinkage long sys_nice(int increment)
  			return -EPERM;
  		if (increment < -40)
  			increment = -40;
@@ -20231,46 +20262,6 @@
  	}
  	if (increment > 40)
  		increment = 40;
-@@ -1288,12 +1297,23 @@ void reparent_to_init(void)
- 
- 	write_lock_irq(&tasklist_lock);
- 
-+#ifdef CONFIG_GRKERNSEC
-+	write_lock(&grsec_exec_file_lock);
-+	if (this_task->exec_file) {
-+		fput(this_task->exec_file);
-+		this_task->exec_file = NULL;
-+	}
-+	write_unlock(&grsec_exec_file_lock);
-+#endif
-+
- 	/* Reparent to init */
- 	REMOVE_LINKS(this_task);
- 	this_task->p_pptr = child_reaper;
- 	this_task->p_opptr = child_reaper;
- 	SET_LINKS(this_task);
- 
-+	gr_set_kernel_label(this_task);
-+
- 	/* Set the exit signal to SIGCHLD so we signal init on exit */
- 	this_task->exit_signal = SIGCHLD;
- 
-@@ -1327,6 +1347,15 @@ void daemonize(void)
- {
- 	struct fs_struct *fs;
- 
-+#ifdef CONFIG_GRKERNSEC
-+	write_lock(&grsec_exec_file_lock);
-+	if (current->exec_file) {
-+		fput(current->exec_file);
-+		current->exec_file = NULL;
-+	}
-+	write_unlock(&grsec_exec_file_lock);
-+#endif
-+	gr_set_kernel_label(current);
- 
- 	/*
- 	 * If we were started as result of loading a module, close all of the
 diff -urNp linux-2.4.32/kernel/signal.c linux-2.4.32/kernel/signal.c
 --- linux-2.4.32/kernel/signal.c	2004-02-18 08:36:32.000000000 -0500
 +++ linux-2.4.32/kernel/signal.c	2006-01-21 16:36:59.957179384 -0500
@@ -20355,7 +20346,7 @@
 +			return -EACCES;
 +		}
 +
- 		if (niceval < p->nice && !capable(CAP_SYS_NICE))
+ 		if (niceval < task_nice(p) && !capable(CAP_SYS_NICE))
  			error = -EACCES;
  		else
 @@ -417,6 +425,10 @@ asmlinkage long sys_setregid(gid_t rgid,
@@ -21277,10 +21268,13 @@
  		_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN) |
  		_trans(flags, MAP_DENYWRITE, VM_DENYWRITE) |
  		_trans(flags, MAP_EXECUTABLE, VM_EXECUTABLE);
-@@ -392,6 +400,43 @@ static int vma_merge(struct mm_struct * 
+@@ -391,8 +399,44 @@ static int vma_merge(struct mm_struct * 
+ 	return 0;
  }
  
- unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, unsigned long len,
+-unsigned long do_mmap_pgoff(struct mm_struct *mm, struct file * file, 
+-			    unsigned long addr, unsigned long len,
++unsigned long do_mmap_pgoff(struct mm_struct *mm, struct file * file, unsigned long addr, unsigned long len,
 +	unsigned long prot, unsigned long flag, unsigned long pgoff)
 +{
 +	unsigned long ret = -EINVAL;
@@ -21291,7 +21285,7 @@
 +		goto out;
 +#endif
 +
-+	ret = __do_mmap_pgoff(file, addr, len, prot, flag, pgoff);
++	ret = __do_mmap_pgoff(mm, file, addr, len, prot, flag, pgoff);
 +
 +#ifdef CONFIG_GRKERNSEC_PAX_SEGMEXEC
 +	if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && ret < TASK_SIZE && ((flag & MAP_TYPE) == MAP_PRIVATE)
@@ -21317,11 +21311,11 @@
 +	return ret;
 +}
 +
-+unsigned long __do_mmap_pgoff(struct file * file, unsigned long addr, unsigned long len,
- 	unsigned long prot, unsigned long flags, unsigned long pgoff)
++unsigned long __do_mmap_pgoff(struct mm_struct *mm, struct file * file, unsigned long addr, unsigned long len,
+ 			    unsigned long prot, unsigned long flags, 
+ 			    unsigned long pgoff)
  {
- 	struct mm_struct * mm = current->mm;
-@@ -401,6 +446,28 @@ unsigned long do_mmap_pgoff(struct file 
+@@ -402,6 +446,28 @@ unsigned long do_mmap_pgoff(struct mm_st
  	int error;
  	rb_node_t ** rb_link, * rb_parent;
  
@@ -21350,7 +21344,7 @@
  	if (file) {
  		if (!file->f_op || !file->f_op->mmap)
  			return -ENODEV;
-@@ -438,10 +505,35 @@ unsigned long do_mmap_pgoff(struct file 
+@@ -439,10 +505,35 @@ unsigned long do_mmap_pgoff(struct mm_st
  	 */
  	vm_flags = calc_vm_flags(prot,flags) | mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
  
@@ -21386,7 +21380,7 @@
  		if (locked > current->rlim[RLIMIT_MEMLOCK].rlim_cur)
  			return -EAGAIN;
  	}
-@@ -486,6 +578,9 @@ unsigned long do_mmap_pgoff(struct file 
+@@ -487,6 +578,9 @@ unsigned long do_mmap_pgoff(struct mm_st
  		}
  	}
  
@@ -21396,7 +21390,7 @@
  	/* Clear old maps */
  munmap_back:
  	vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
-@@ -496,6 +591,7 @@ munmap_back:
+@@ -497,6 +591,7 @@ munmap_back:
  	}
  
  	/* Check against address space limit. */
@@ -21404,7 +21398,7 @@
  	if ((mm->total_vm << PAGE_SHIFT) + len
  	    > current->rlim[RLIMIT_AS].rlim_cur)
  		return -ENOMEM;
-@@ -523,11 +619,19 @@ munmap_back:
+@@ -524,11 +619,19 @@ munmap_back:
  	vma->vm_start = addr;
  	vma->vm_end = addr + len;
  	vma->vm_flags = vm_flags;
@@ -21424,7 +21418,7 @@
  	vma->vm_raend = 0;
  
  	if (file) {
-@@ -551,6 +655,14 @@ munmap_back:
+@@ -552,6 +655,14 @@ munmap_back:
  			goto free_vma;
  	}
  
@@ -21439,18 +21433,18 @@
  	/* Can addr have changed??
  	 *
  	 * Answer: Yes, several device drivers can do it in their
-@@ -621,22 +733,39 @@ free_vma:
+@@ -622,22 +733,39 @@ free_vma:
  static inline unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
  {
  	struct vm_area_struct *vma;
 +	unsigned long task_size = TASK_SIZE;
- 
--	if (len > TASK_SIZE)
++
 +#ifdef CONFIG_GRKERNSEC_PAX_SEGMEXEC
 +	if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
 +		task_size = SEGMEXEC_TASK_SIZE;
 +#endif
-+
+ 
+-	if (len > TASK_SIZE)
 +	if (len > task_size)
  		return -ENOMEM;
  
@@ -21482,7 +21476,7 @@
  			return -ENOMEM;
  		if (!vma || addr + len <= vma->vm_start)
  			return addr;
-@@ -842,6 +971,7 @@ static struct vm_area_struct * unmap_fix
+@@ -843,6 +971,7 @@ static struct vm_area_struct * unmap_fix
  		mpnt->vm_pgoff = area->vm_pgoff + ((end - area->vm_start) >> PAGE_SHIFT);
  		mpnt->vm_file = area->vm_file;
  		mpnt->vm_private_data = area->vm_private_data;
@@ -21490,7 +21484,7 @@
  		if (mpnt->vm_file)
  			get_file(mpnt->vm_file);
  		if (mpnt->vm_ops && mpnt->vm_ops->open)
-@@ -876,7 +1006,7 @@ static struct vm_area_struct * unmap_fix
+@@ -877,7 +1006,7 @@ static struct vm_area_struct * unmap_fix
   * we just free'd - but there's no telling how much before.
   */
  static void free_pgtables(struct mm_struct * mm, struct vm_area_struct *prev,
@@ -21499,7 +21493,7 @@
  {
  	unsigned long first = start & PGDIR_MASK;
  	unsigned long last = end + PGDIR_SIZE - 1;
-@@ -908,6 +1038,14 @@ static void free_pgtables(struct mm_stru
+@@ -909,6 +1038,14 @@ static void free_pgtables(struct mm_stru
  		break;
  	}
  no_mmaps:
@@ -21514,7 +21508,7 @@
  	if (last < first)
  		return;
  	/*
-@@ -922,6 +1060,83 @@ no_mmaps:
+@@ -923,6 +1060,89 @@ no_mmaps:
  	}
  }
  
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/grsecurity-2.1.8-2.4.32-200601211647.patch?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list