Author: qboosh                       Date: Thu Nov 17 18:27:23 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- adapted for PLD kernel

---- Files affected:
SOURCES:
   grsecurity-2.1.7-2.4.32-200511131857.patch (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/grsecurity-2.1.7-2.4.32-200511131857.patch
diff -u SOURCES/grsecurity-2.1.7-2.4.32-200511131857.patch:1.1 
SOURCES/grsecurity-2.1.7-2.4.32-200511131857.patch:1.2
--- SOURCES/grsecurity-2.1.7-2.4.32-200511131857.patch:1.1      Thu Nov 17 
10:54:31 2005
+++ SOURCES/grsecurity-2.1.7-2.4.32-200511131857.patch  Thu Nov 17 19:27:17 2005
@@ -950,15 +950,6 @@
 diff -urNp linux-2.4.32/Makefile linux-2.4.32/Makefile
 --- linux-2.4.32/Makefile      2005-11-11 23:57:17.000000000 -0500
 +++ linux-2.4.32/Makefile      2005-11-12 00:00:06.000000000 -0500
-@@ -1,7 +1,7 @@
- VERSION = 2
- PATCHLEVEL = 4
- SUBLEVEL = 32
--EXTRAVERSION =
-+EXTRAVERSION = -grsec
- 
- KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
- 
 @@ -126,9 +126,10 @@ export SVGA_MODE = -DSVGA_MODE=NORMAL_VG
  
  CORE_FILES    =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o
@@ -2235,7 +2226,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
@@ -6401,7 +6392,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;
@@ -6694,8 +6685,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:
@@ -6705,12 +6696,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
@@ -7109,7 +7098,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
@@ -7467,7 +7456,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
@@ -7492,20 +7481,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
 +
@@ -8211,7 +8200,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) {
@@ -8226,15 +8215,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;
@@ -8269,7 +8259,7 @@
        up(&dir->d_inode->i_sem);
  
        error = -EEXIST;
-@@ -1158,7 +1221,7 @@ ok:
+@@ -1159,7 +1222,7 @@ ok:
                if (!error) {
                        DQUOT_INIT(inode);
                        
@@ -8278,7 +8268,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.
         */
@@ -8292,9 +8282,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)) {
@@ -8312,7 +8302,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;
                }
@@ -8326,26 +8316,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;
@@ -8354,7 +8343,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)) {
@@ -8378,7 +8367,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;
@@ -8387,7 +8376,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;
@@ -8410,7 +8399,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)) {
@@ -8427,7 +8416,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)) {
@@ -8456,7 +8445,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;
  
@@ -14750,7 +14739,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;
@@ -17322,9 +17311,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        2005-11-11 23:59:48.000000000 
-0500
@@ -19239,7 +19228,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);
 +
@@ -19474,7 +19463,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
@@ -19791,15 +19780,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 2005-11-11 23:59:49.000000000 -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
@@ -19934,10 +19968,10 @@
 diff -urNp linux-2.4.32/kernel/printk.c linux-2.4.32/kernel/printk.c
 --- linux-2.4.32/kernel/printk.c       2004-11-17 06:54:22.000000000 -0500
 +++ linux-2.4.32/kernel/printk.c       2005-11-11 23:59:49.000000000 -0500
-@@ -26,6 +26,7 @@
- #include <linux/module.h>
+@@ -27,6 +27,7 @@
  #include <linux/interrupt.h>                  /* For in_interrupt() */
  #include <linux/config.h>
+ #include <linux/delay.h>
 +#include <linux/grsecurity.h>
  
  #include <asm/uaccess.h>
@@ -19957,27 +19991,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        2005-11-11 23:59:49.000000000 -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;
@@ -19987,46 +20009,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       2005-11-11 23:59:49.000000000 -0500
@@ -20111,7 +20093,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,
@@ -21023,10 +21005,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;
@@ -21037,7 +21022,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)
@@ -21050,9 +21035,9 @@
 +      {
 +              unsigned long ret_m;
 +              prot = prot & PROT_EXEC ? prot : PROT_NONE;
-+              ret_m = __do_mmap_pgoff(NULL, ret + SEGMEXEC_TASK_SIZE, 0UL, 
prot, flag | MAP_MIRROR | MAP_FIXED, ret);
++              ret_m = __do_mmap_pgoff(mm, NULL, ret + SEGMEXEC_TASK_SIZE, 
0UL, prot, flag | MAP_MIRROR | MAP_FIXED, ret);
 +              if (ret_m >= TASK_SIZE) {
-+                      do_munmap(current->mm, ret, len);
++                      do_munmap(mm, ret, len);
 +                      ret = ret_m;
 +              }
 +      }
@@ -21063,11 +21048,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;
  
@@ -21096,7 +21081,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;
  
@@ -21132,7 +21117,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
                }
        }
  
@@ -21142,7 +21127,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. */
@@ -21150,7 +21135,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;
@@ -21170,7 +21155,7 @@
        vma->vm_raend = 0;
  
        if (file) {
-@@ -551,6 +655,14 @@ munmap_back:
+@@ -552,6 +655,14 @@ munmap_back:
                        goto free_vma;
        }
  
@@ -21185,18 +21170,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;
  
@@ -21228,7 +21213,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
<<Diff was trimmed, longer than 597 lines>>

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

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to