aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-08-26 10:02:58 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-08-26 10:02:58 +0000
commitefcd7ef99b94fa79dd054e99cba9175eaa557fb1 (patch)
treed7ed0a4268e1af2e1c6518167593d11f6a95b22b
parentd7cd11cbe56f55cf7adfb73f3041b7a87c7dab4d (diff)
downloadalpine_aports-efcd7ef99b94fa79dd054e99cba9175eaa557fb1.tar.bz2
alpine_aports-efcd7ef99b94fa79dd054e99cba9175eaa557fb1.tar.xz
alpine_aports-efcd7ef99b94fa79dd054e99cba9175eaa557fb1.zip
main/linux-grsec: upgrade to grsecurity-2.2.2-3.0.3-201108251825
-rw-r--r--main/linux-grsec/APKBUILD6
-rw-r--r--main/linux-grsec/grsecurity-2.2.2-3.0.3-201108251825.patch (renamed from main/linux-grsec/grsecurity-2.2.2-3.0.3-201108241901.patch)408
2 files changed, 263 insertions, 151 deletions
diff --git a/main/linux-grsec/APKBUILD b/main/linux-grsec/APKBUILD
index 985985988d..60813e21fe 100644
--- a/main/linux-grsec/APKBUILD
+++ b/main/linux-grsec/APKBUILD
@@ -4,7 +4,7 @@ _flavor=grsec
4pkgname=linux-${_flavor} 4pkgname=linux-${_flavor}
5pkgver=3.0.3 5pkgver=3.0.3
6_kernver=3.0 6_kernver=3.0
7pkgrel=0 7pkgrel=1
8pkgdesc="Linux kernel with grsecurity" 8pkgdesc="Linux kernel with grsecurity"
9url=http://grsecurity.net 9url=http://grsecurity.net
10depends="mkinitfs linux-firmware" 10depends="mkinitfs linux-firmware"
@@ -14,7 +14,7 @@ _config=${config:-kernelconfig.${CARCH}}
14install= 14install=
15source="ftp://ftp.kernel.org/pub/linux/kernel/v3.0/linux-$_kernver.tar.bz2 15source="ftp://ftp.kernel.org/pub/linux/kernel/v3.0/linux-$_kernver.tar.bz2
16 ftp://ftp.kernel.org/pub/linux/kernel/v3.0/patch-$pkgver.bz2 16 ftp://ftp.kernel.org/pub/linux/kernel/v3.0/patch-$pkgver.bz2
17 grsecurity-2.2.2-3.0.3-201108241901.patch 17 grsecurity-2.2.2-3.0.3-201108251825.patch
18 18
19 0004-arp-flush-arp-cache-on-device-change.patch 19 0004-arp-flush-arp-cache-on-device-change.patch
20 20
@@ -138,7 +138,7 @@ dev() {
138 138
139md5sums="398e95866794def22b12dfbc15ce89c0 linux-3.0.tar.bz2 139md5sums="398e95866794def22b12dfbc15ce89c0 linux-3.0.tar.bz2
1401757786b9a9ffbd48ad9642199ff5bd7 patch-3.0.3.bz2 1401757786b9a9ffbd48ad9642199ff5bd7 patch-3.0.3.bz2
1419709493d471fc64e342345c1bb5b082b grsecurity-2.2.2-3.0.3-201108241901.patch 141dbf71c02960bdb9e047ed6ccd61e108e grsecurity-2.2.2-3.0.3-201108251825.patch
142776adeeb5272093574f8836c5037dd7d 0004-arp-flush-arp-cache-on-device-change.patch 142776adeeb5272093574f8836c5037dd7d 0004-arp-flush-arp-cache-on-device-change.patch
143406e62e430cee7ba3bb37be341d9ff3e kernelconfig.x86 143406e62e430cee7ba3bb37be341d9ff3e kernelconfig.x86
1446957efc9f017c59b05aa0a2e4167255e kernelconfig.x86_64" 1446957efc9f017c59b05aa0a2e4167255e kernelconfig.x86_64"
diff --git a/main/linux-grsec/grsecurity-2.2.2-3.0.3-201108241901.patch b/main/linux-grsec/grsecurity-2.2.2-3.0.3-201108251825.patch
index a30bf0fd50..04ec669e61 100644
--- a/main/linux-grsec/grsecurity-2.2.2-3.0.3-201108241901.patch
+++ b/main/linux-grsec/grsecurity-2.2.2-3.0.3-201108251825.patch
@@ -5603,7 +5603,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32_aout.c linux-3.0.3/arch/x86/ia32/ia32_
5603 has_dumped = 1; 5603 has_dumped = 1;
5604diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32entry.S 5604diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32entry.S
5605--- linux-3.0.3/arch/x86/ia32/ia32entry.S 2011-07-21 22:17:23.000000000 -0400 5605--- linux-3.0.3/arch/x86/ia32/ia32entry.S 2011-07-21 22:17:23.000000000 -0400
5606+++ linux-3.0.3/arch/x86/ia32/ia32entry.S 2011-08-23 21:48:14.000000000 -0400 5606+++ linux-3.0.3/arch/x86/ia32/ia32entry.S 2011-08-25 17:36:37.000000000 -0400
5607@@ -13,6 +13,7 @@ 5607@@ -13,6 +13,7 @@
5608 #include <asm/thread_info.h> 5608 #include <asm/thread_info.h>
5609 #include <asm/segment.h> 5609 #include <asm/segment.h>
@@ -5612,7 +5612,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5612 #include <linux/linkage.h> 5612 #include <linux/linkage.h>
5613 5613
5614 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */ 5614 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
5615@@ -95,6 +96,32 @@ ENTRY(native_irq_enable_sysexit) 5615@@ -95,6 +96,29 @@ ENTRY(native_irq_enable_sysexit)
5616 ENDPROC(native_irq_enable_sysexit) 5616 ENDPROC(native_irq_enable_sysexit)
5617 #endif 5617 #endif
5618 5618
@@ -5631,9 +5631,6 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5631+ call pax_randomize_kstack 5631+ call pax_randomize_kstack
5632+ popq %rax 5632+ popq %rax
5633+#endif 5633+#endif
5634+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
5635+ call pax_erase_kstack
5636+#endif
5637+ .endm 5634+ .endm
5638+ 5635+
5639+ .macro pax_erase_kstack 5636+ .macro pax_erase_kstack
@@ -5645,7 +5642,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5645 /* 5642 /*
5646 * 32bit SYSENTER instruction entry. 5643 * 32bit SYSENTER instruction entry.
5647 * 5644 *
5648@@ -121,7 +148,7 @@ ENTRY(ia32_sysenter_target) 5645@@ -121,7 +145,7 @@ ENTRY(ia32_sysenter_target)
5649 CFI_REGISTER rsp,rbp 5646 CFI_REGISTER rsp,rbp
5650 SWAPGS_UNSAFE_STACK 5647 SWAPGS_UNSAFE_STACK
5651 movq PER_CPU_VAR(kernel_stack), %rsp 5648 movq PER_CPU_VAR(kernel_stack), %rsp
@@ -5654,7 +5651,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5654 /* 5651 /*
5655 * No need to follow this irqs on/off section: the syscall 5652 * No need to follow this irqs on/off section: the syscall
5656 * disabled irqs, here we enable it straight after entry: 5653 * disabled irqs, here we enable it straight after entry:
5657@@ -134,7 +161,8 @@ ENTRY(ia32_sysenter_target) 5654@@ -134,7 +158,8 @@ ENTRY(ia32_sysenter_target)
5658 CFI_REL_OFFSET rsp,0 5655 CFI_REL_OFFSET rsp,0
5659 pushfq_cfi 5656 pushfq_cfi
5660 /*CFI_REL_OFFSET rflags,0*/ 5657 /*CFI_REL_OFFSET rflags,0*/
@@ -5664,7 +5661,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5664 CFI_REGISTER rip,r10 5661 CFI_REGISTER rip,r10
5665 pushq_cfi $__USER32_CS 5662 pushq_cfi $__USER32_CS
5666 /*CFI_REL_OFFSET cs,0*/ 5663 /*CFI_REL_OFFSET cs,0*/
5667@@ -146,6 +174,12 @@ ENTRY(ia32_sysenter_target) 5664@@ -146,6 +171,12 @@ ENTRY(ia32_sysenter_target)
5668 SAVE_ARGS 0,0,1 5665 SAVE_ARGS 0,0,1
5669 /* no need to do an access_ok check here because rbp has been 5666 /* no need to do an access_ok check here because rbp has been
5670 32bit zero extended */ 5667 32bit zero extended */
@@ -5677,15 +5674,16 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5677 1: movl (%rbp),%ebp 5674 1: movl (%rbp),%ebp
5678 .section __ex_table,"a" 5675 .section __ex_table,"a"
5679 .quad 1b,ia32_badarg 5676 .quad 1b,ia32_badarg
5680@@ -168,6 +202,7 @@ sysenter_dispatch: 5677@@ -168,6 +199,8 @@ sysenter_dispatch:
5681 testl $_TIF_ALLWORK_MASK,TI_flags(%r10) 5678 testl $_TIF_ALLWORK_MASK,TI_flags(%r10)
5682 jnz sysexit_audit 5679 jnz sysexit_audit
5683 sysexit_from_sys_call: 5680 sysexit_from_sys_call:
5684+ pax_exit_kernel_user 5681+ pax_exit_kernel_user
5682+ pax_erase_kstack
5685 andl $~TS_COMPAT,TI_status(%r10) 5683 andl $~TS_COMPAT,TI_status(%r10)
5686 /* clear IF, that popfq doesn't enable interrupts early */ 5684 /* clear IF, that popfq doesn't enable interrupts early */
5687 andl $~0x200,EFLAGS-R11(%rsp) 5685 andl $~0x200,EFLAGS-R11(%rsp)
5688@@ -194,6 +229,9 @@ sysexit_from_sys_call: 5686@@ -194,6 +227,9 @@ sysexit_from_sys_call:
5689 movl %eax,%esi /* 2nd arg: syscall number */ 5687 movl %eax,%esi /* 2nd arg: syscall number */
5690 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */ 5688 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
5691 call audit_syscall_entry 5689 call audit_syscall_entry
@@ -5695,7 +5693,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5695 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */ 5693 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
5696 cmpq $(IA32_NR_syscalls-1),%rax 5694 cmpq $(IA32_NR_syscalls-1),%rax
5697 ja ia32_badsys 5695 ja ia32_badsys
5698@@ -246,6 +284,9 @@ sysenter_tracesys: 5696@@ -246,6 +282,9 @@ sysenter_tracesys:
5699 movq $-ENOSYS,RAX(%rsp)/* ptrace can change this for a bad syscall */ 5697 movq $-ENOSYS,RAX(%rsp)/* ptrace can change this for a bad syscall */
5700 movq %rsp,%rdi /* &pt_regs -> arg1 */ 5698 movq %rsp,%rdi /* &pt_regs -> arg1 */
5701 call syscall_trace_enter 5699 call syscall_trace_enter
@@ -5705,7 +5703,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5705 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */ 5703 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
5706 RESTORE_REST 5704 RESTORE_REST
5707 cmpq $(IA32_NR_syscalls-1),%rax 5705 cmpq $(IA32_NR_syscalls-1),%rax
5708@@ -277,19 +318,24 @@ ENDPROC(ia32_sysenter_target) 5706@@ -277,19 +316,24 @@ ENDPROC(ia32_sysenter_target)
5709 ENTRY(ia32_cstar_target) 5707 ENTRY(ia32_cstar_target)
5710 CFI_STARTPROC32 simple 5708 CFI_STARTPROC32 simple
5711 CFI_SIGNAL_FRAME 5709 CFI_SIGNAL_FRAME
@@ -5732,7 +5730,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5732 movl %eax,%eax /* zero extension */ 5730 movl %eax,%eax /* zero extension */
5733 movq %rax,ORIG_RAX-ARGOFFSET(%rsp) 5731 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
5734 movq %rcx,RIP-ARGOFFSET(%rsp) 5732 movq %rcx,RIP-ARGOFFSET(%rsp)
5735@@ -305,6 +351,12 @@ ENTRY(ia32_cstar_target) 5733@@ -305,6 +349,12 @@ ENTRY(ia32_cstar_target)
5736 /* no need to do an access_ok check here because r8 has been 5734 /* no need to do an access_ok check here because r8 has been
5737 32bit zero extended */ 5735 32bit zero extended */
5738 /* hardware stack frame is complete now */ 5736 /* hardware stack frame is complete now */
@@ -5745,15 +5743,16 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5745 1: movl (%r8),%r9d 5743 1: movl (%r8),%r9d
5746 .section __ex_table,"a" 5744 .section __ex_table,"a"
5747 .quad 1b,ia32_badarg 5745 .quad 1b,ia32_badarg
5748@@ -327,6 +379,7 @@ cstar_dispatch: 5746@@ -327,6 +377,8 @@ cstar_dispatch:
5749 testl $_TIF_ALLWORK_MASK,TI_flags(%r10) 5747 testl $_TIF_ALLWORK_MASK,TI_flags(%r10)
5750 jnz sysretl_audit 5748 jnz sysretl_audit
5751 sysretl_from_sys_call: 5749 sysretl_from_sys_call:
5752+ pax_exit_kernel_user 5750+ pax_exit_kernel_user
5751+ pax_erase_kstack
5753 andl $~TS_COMPAT,TI_status(%r10) 5752 andl $~TS_COMPAT,TI_status(%r10)
5754 RESTORE_ARGS 1,-ARG_SKIP,1,1,1 5753 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
5755 movl RIP-ARGOFFSET(%rsp),%ecx 5754 movl RIP-ARGOFFSET(%rsp),%ecx
5756@@ -364,6 +417,9 @@ cstar_tracesys: 5755@@ -364,6 +416,9 @@ cstar_tracesys:
5757 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */ 5756 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
5758 movq %rsp,%rdi /* &pt_regs -> arg1 */ 5757 movq %rsp,%rdi /* &pt_regs -> arg1 */
5759 call syscall_trace_enter 5758 call syscall_trace_enter
@@ -5763,7 +5762,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5763 LOAD_ARGS32 ARGOFFSET, 1 /* reload args from stack in case ptrace changed it */ 5762 LOAD_ARGS32 ARGOFFSET, 1 /* reload args from stack in case ptrace changed it */
5764 RESTORE_REST 5763 RESTORE_REST
5765 xchgl %ebp,%r9d 5764 xchgl %ebp,%r9d
5766@@ -409,6 +465,7 @@ ENTRY(ia32_syscall) 5765@@ -409,6 +464,7 @@ ENTRY(ia32_syscall)
5767 CFI_REL_OFFSET rip,RIP-RIP 5766 CFI_REL_OFFSET rip,RIP-RIP
5768 PARAVIRT_ADJUST_EXCEPTION_FRAME 5767 PARAVIRT_ADJUST_EXCEPTION_FRAME
5769 SWAPGS 5768 SWAPGS
@@ -5771,7 +5770,7 @@ diff -urNp linux-3.0.3/arch/x86/ia32/ia32entry.S linux-3.0.3/arch/x86/ia32/ia32e
5771 /* 5770 /*
5772 * No need to follow this irqs on/off section: the syscall 5771 * No need to follow this irqs on/off section: the syscall
5773 * disabled irqs and here we enable it straight after entry: 5772 * disabled irqs and here we enable it straight after entry:
5774@@ -441,6 +498,9 @@ ia32_tracesys: 5773@@ -441,6 +497,9 @@ ia32_tracesys:
5775 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */ 5774 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
5776 movq %rsp,%rdi /* &pt_regs -> arg1 */ 5775 movq %rsp,%rdi /* &pt_regs -> arg1 */
5777 call syscall_trace_enter 5776 call syscall_trace_enter
@@ -11740,7 +11739,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_32.S linux-3.0.3/arch/x86/kernel/en
11740 CFI_ADJUST_CFA_OFFSET -24 11739 CFI_ADJUST_CFA_OFFSET -24
11741diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/entry_64.S 11740diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/entry_64.S
11742--- linux-3.0.3/arch/x86/kernel/entry_64.S 2011-07-21 22:17:23.000000000 -0400 11741--- linux-3.0.3/arch/x86/kernel/entry_64.S 2011-07-21 22:17:23.000000000 -0400
11743+++ linux-3.0.3/arch/x86/kernel/entry_64.S 2011-08-23 21:48:14.000000000 -0400 11742+++ linux-3.0.3/arch/x86/kernel/entry_64.S 2011-08-25 17:38:59.000000000 -0400
11744@@ -53,6 +53,7 @@ 11743@@ -53,6 +53,7 @@
11745 #include <asm/paravirt.h> 11744 #include <asm/paravirt.h>
11746 #include <asm/ftrace.h> 11745 #include <asm/ftrace.h>
@@ -11749,7 +11748,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
11749 11748
11750 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */ 11749 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11751 #include <linux/elf-em.h> 11750 #include <linux/elf-em.h>
11752@@ -176,6 +177,259 @@ ENTRY(native_usergs_sysret64) 11751@@ -176,6 +177,262 @@ ENTRY(native_usergs_sysret64)
11753 ENDPROC(native_usergs_sysret64) 11752 ENDPROC(native_usergs_sysret64)
11754 #endif /* CONFIG_PARAVIRT */ 11753 #endif /* CONFIG_PARAVIRT */
11755 11754
@@ -11846,9 +11845,6 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
11846+ call pax_randomize_kstack 11845+ call pax_randomize_kstack
11847+ pop %rax 11846+ pop %rax
11848+#endif 11847+#endif
11849+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11850+ call pax_erase_kstack
11851+#endif
11852+ .endm 11848+ .endm
11853+ 11849+
11854+#ifdef CONFIG_PAX_MEMORY_UDEREF 11850+#ifdef CONFIG_PAX_MEMORY_UDEREF
@@ -11994,6 +11990,12 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
11994+2: cld 11990+2: cld
11995+ mov %esp, %ecx 11991+ mov %esp, %ecx
11996+ sub %edi, %ecx 11992+ sub %edi, %ecx
11993+
11994+ cmp $THREAD_SIZE_asm, %rcx
11995+ jb 3f
11996+ ud2
11997+3:
11998+
11997+ shr $3, %ecx 11999+ shr $3, %ecx
11998+ rep stosq 12000+ rep stosq
11999+ 12001+
@@ -12009,7 +12011,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12009 12011
12010 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET 12012 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
12011 #ifdef CONFIG_TRACE_IRQFLAGS 12013 #ifdef CONFIG_TRACE_IRQFLAGS
12012@@ -318,7 +572,7 @@ ENTRY(save_args) 12014@@ -318,7 +575,7 @@ ENTRY(save_args)
12013 leaq -RBP+8(%rsp),%rdi /* arg1 for handler */ 12015 leaq -RBP+8(%rsp),%rdi /* arg1 for handler */
12014 movq_cfi rbp, 8 /* push %rbp */ 12016 movq_cfi rbp, 8 /* push %rbp */
12015 leaq 8(%rsp), %rbp /* mov %rsp, %ebp */ 12017 leaq 8(%rsp), %rbp /* mov %rsp, %ebp */
@@ -12018,7 +12020,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12018 je 1f 12020 je 1f
12019 SWAPGS 12021 SWAPGS
12020 /* 12022 /*
12021@@ -409,7 +663,7 @@ ENTRY(ret_from_fork) 12023@@ -409,7 +666,7 @@ ENTRY(ret_from_fork)
12022 12024
12023 RESTORE_REST 12025 RESTORE_REST
12024 12026
@@ -12027,7 +12029,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12027 je int_ret_from_sys_call 12029 je int_ret_from_sys_call
12028 12030
12029 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET 12031 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
12030@@ -455,7 +709,7 @@ END(ret_from_fork) 12032@@ -455,7 +712,7 @@ END(ret_from_fork)
12031 ENTRY(system_call) 12033 ENTRY(system_call)
12032 CFI_STARTPROC simple 12034 CFI_STARTPROC simple
12033 CFI_SIGNAL_FRAME 12035 CFI_SIGNAL_FRAME
@@ -12036,7 +12038,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12036 CFI_REGISTER rip,rcx 12038 CFI_REGISTER rip,rcx
12037 /*CFI_REGISTER rflags,r11*/ 12039 /*CFI_REGISTER rflags,r11*/
12038 SWAPGS_UNSAFE_STACK 12040 SWAPGS_UNSAFE_STACK
12039@@ -468,12 +722,13 @@ ENTRY(system_call_after_swapgs) 12041@@ -468,12 +725,13 @@ ENTRY(system_call_after_swapgs)
12040 12042
12041 movq %rsp,PER_CPU_VAR(old_rsp) 12043 movq %rsp,PER_CPU_VAR(old_rsp)
12042 movq PER_CPU_VAR(kernel_stack),%rsp 12044 movq PER_CPU_VAR(kernel_stack),%rsp
@@ -12051,15 +12053,16 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12051 movq %rax,ORIG_RAX-ARGOFFSET(%rsp) 12053 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
12052 movq %rcx,RIP-ARGOFFSET(%rsp) 12054 movq %rcx,RIP-ARGOFFSET(%rsp)
12053 CFI_REL_OFFSET rip,RIP-ARGOFFSET 12055 CFI_REL_OFFSET rip,RIP-ARGOFFSET
12054@@ -502,6 +757,7 @@ sysret_check: 12056@@ -502,6 +760,8 @@ sysret_check:
12055 andl %edi,%edx 12057 andl %edi,%edx
12056 jnz sysret_careful 12058 jnz sysret_careful
12057 CFI_REMEMBER_STATE 12059 CFI_REMEMBER_STATE
12058+ pax_exit_kernel_user 12060+ pax_exit_kernel_user
12061+ pax_erase_kstack
12059 /* 12062 /*
12060 * sysretq will re-enable interrupts: 12063 * sysretq will re-enable interrupts:
12061 */ 12064 */
12062@@ -560,6 +816,9 @@ auditsys: 12065@@ -560,6 +820,9 @@ auditsys:
12063 movq %rax,%rsi /* 2nd arg: syscall number */ 12066 movq %rax,%rsi /* 2nd arg: syscall number */
12064 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */ 12067 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
12065 call audit_syscall_entry 12068 call audit_syscall_entry
@@ -12069,7 +12072,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12069 LOAD_ARGS 0 /* reload call-clobbered registers */ 12072 LOAD_ARGS 0 /* reload call-clobbered registers */
12070 jmp system_call_fastpath 12073 jmp system_call_fastpath
12071 12074
12072@@ -590,6 +849,9 @@ tracesys: 12075@@ -590,6 +853,9 @@ tracesys:
12073 FIXUP_TOP_OF_STACK %rdi 12076 FIXUP_TOP_OF_STACK %rdi
12074 movq %rsp,%rdi 12077 movq %rsp,%rdi
12075 call syscall_trace_enter 12078 call syscall_trace_enter
@@ -12079,7 +12082,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12079 /* 12082 /*
12080 * Reload arg registers from stack in case ptrace changed them. 12083 * Reload arg registers from stack in case ptrace changed them.
12081 * We don't reload %rax because syscall_trace_enter() returned 12084 * We don't reload %rax because syscall_trace_enter() returned
12082@@ -611,7 +873,7 @@ tracesys: 12085@@ -611,7 +877,7 @@ tracesys:
12083 GLOBAL(int_ret_from_sys_call) 12086 GLOBAL(int_ret_from_sys_call)
12084 DISABLE_INTERRUPTS(CLBR_NONE) 12087 DISABLE_INTERRUPTS(CLBR_NONE)
12085 TRACE_IRQS_OFF 12088 TRACE_IRQS_OFF
@@ -12088,7 +12091,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12088 je retint_restore_args 12091 je retint_restore_args
12089 movl $_TIF_ALLWORK_MASK,%edi 12092 movl $_TIF_ALLWORK_MASK,%edi
12090 /* edi: mask to check */ 12093 /* edi: mask to check */
12091@@ -793,6 +1055,16 @@ END(interrupt) 12094@@ -793,6 +1059,16 @@ END(interrupt)
12092 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP 12095 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
12093 call save_args 12096 call save_args
12094 PARTIAL_FRAME 0 12097 PARTIAL_FRAME 0
@@ -12105,7 +12108,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12105 call \func 12108 call \func
12106 .endm 12109 .endm
12107 12110
12108@@ -825,7 +1097,7 @@ ret_from_intr: 12111@@ -825,7 +1101,7 @@ ret_from_intr:
12109 CFI_ADJUST_CFA_OFFSET -8 12112 CFI_ADJUST_CFA_OFFSET -8
12110 exit_intr: 12113 exit_intr:
12111 GET_THREAD_INFO(%rcx) 12114 GET_THREAD_INFO(%rcx)
@@ -12114,11 +12117,12 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12114 je retint_kernel 12117 je retint_kernel
12115 12118
12116 /* Interrupt came from user space */ 12119 /* Interrupt came from user space */
12117@@ -847,12 +1119,14 @@ retint_swapgs: /* return to user-space 12120@@ -847,12 +1123,15 @@ retint_swapgs: /* return to user-space
12118 * The iretq could re-enable interrupts: 12121 * The iretq could re-enable interrupts:
12119 */ 12122 */
12120 DISABLE_INTERRUPTS(CLBR_ANY) 12123 DISABLE_INTERRUPTS(CLBR_ANY)
12121+ pax_exit_kernel_user 12124+ pax_exit_kernel_user
12125+ pax_erase_kstack
12122 TRACE_IRQS_IRETQ 12126 TRACE_IRQS_IRETQ
12123 SWAPGS 12127 SWAPGS
12124 jmp restore_args 12128 jmp restore_args
@@ -12129,7 +12133,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12129 /* 12133 /*
12130 * The iretq could re-enable interrupts: 12134 * The iretq could re-enable interrupts:
12131 */ 12135 */
12132@@ -1027,6 +1301,16 @@ ENTRY(\sym) 12136@@ -1027,6 +1306,16 @@ ENTRY(\sym)
12133 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 12137 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
12134 call error_entry 12138 call error_entry
12135 DEFAULT_FRAME 0 12139 DEFAULT_FRAME 0
@@ -12146,7 +12150,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12146 movq %rsp,%rdi /* pt_regs pointer */ 12150 movq %rsp,%rdi /* pt_regs pointer */
12147 xorl %esi,%esi /* no error code */ 12151 xorl %esi,%esi /* no error code */
12148 call \do_sym 12152 call \do_sym
12149@@ -1044,6 +1328,16 @@ ENTRY(\sym) 12153@@ -1044,6 +1333,16 @@ ENTRY(\sym)
12150 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 12154 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
12151 call save_paranoid 12155 call save_paranoid
12152 TRACE_IRQS_OFF 12156 TRACE_IRQS_OFF
@@ -12163,7 +12167,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12163 movq %rsp,%rdi /* pt_regs pointer */ 12167 movq %rsp,%rdi /* pt_regs pointer */
12164 xorl %esi,%esi /* no error code */ 12168 xorl %esi,%esi /* no error code */
12165 call \do_sym 12169 call \do_sym
12166@@ -1052,7 +1346,7 @@ ENTRY(\sym) 12170@@ -1052,7 +1351,7 @@ ENTRY(\sym)
12167 END(\sym) 12171 END(\sym)
12168 .endm 12172 .endm
12169 12173
@@ -12172,7 +12176,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12172 .macro paranoidzeroentry_ist sym do_sym ist 12176 .macro paranoidzeroentry_ist sym do_sym ist
12173 ENTRY(\sym) 12177 ENTRY(\sym)
12174 INTR_FRAME 12178 INTR_FRAME
12175@@ -1062,8 +1356,24 @@ ENTRY(\sym) 12179@@ -1062,8 +1361,24 @@ ENTRY(\sym)
12176 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 12180 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
12177 call save_paranoid 12181 call save_paranoid
12178 TRACE_IRQS_OFF 12182 TRACE_IRQS_OFF
@@ -12197,7 +12201,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12197 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist) 12201 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
12198 call \do_sym 12202 call \do_sym
12199 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist) 12203 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
12200@@ -1080,6 +1390,16 @@ ENTRY(\sym) 12204@@ -1080,6 +1395,16 @@ ENTRY(\sym)
12201 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 12205 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
12202 call error_entry 12206 call error_entry
12203 DEFAULT_FRAME 0 12207 DEFAULT_FRAME 0
@@ -12214,7 +12218,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12214 movq %rsp,%rdi /* pt_regs pointer */ 12218 movq %rsp,%rdi /* pt_regs pointer */
12215 movq ORIG_RAX(%rsp),%rsi /* get error code */ 12219 movq ORIG_RAX(%rsp),%rsi /* get error code */
12216 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */ 12220 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
12217@@ -1099,6 +1419,16 @@ ENTRY(\sym) 12221@@ -1099,6 +1424,16 @@ ENTRY(\sym)
12218 call save_paranoid 12222 call save_paranoid
12219 DEFAULT_FRAME 0 12223 DEFAULT_FRAME 0
12220 TRACE_IRQS_OFF 12224 TRACE_IRQS_OFF
@@ -12231,7 +12235,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12231 movq %rsp,%rdi /* pt_regs pointer */ 12235 movq %rsp,%rdi /* pt_regs pointer */
12232 movq ORIG_RAX(%rsp),%rsi /* get error code */ 12236 movq ORIG_RAX(%rsp),%rsi /* get error code */
12233 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */ 12237 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
12234@@ -1361,14 +1691,27 @@ ENTRY(paranoid_exit) 12238@@ -1361,14 +1696,27 @@ ENTRY(paranoid_exit)
12235 TRACE_IRQS_OFF 12239 TRACE_IRQS_OFF
12236 testl %ebx,%ebx /* swapgs needed? */ 12240 testl %ebx,%ebx /* swapgs needed? */
12237 jnz paranoid_restore 12241 jnz paranoid_restore
@@ -12260,7 +12264,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12260 TRACE_IRQS_IRETQ 0 12264 TRACE_IRQS_IRETQ 0
12261 RESTORE_ALL 8 12265 RESTORE_ALL 8
12262 jmp irq_return 12266 jmp irq_return
12263@@ -1426,7 +1769,7 @@ ENTRY(error_entry) 12267@@ -1426,7 +1774,7 @@ ENTRY(error_entry)
12264 movq_cfi r14, R14+8 12268 movq_cfi r14, R14+8
12265 movq_cfi r15, R15+8 12269 movq_cfi r15, R15+8
12266 xorl %ebx,%ebx 12270 xorl %ebx,%ebx
@@ -12269,7 +12273,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12269 je error_kernelspace 12273 je error_kernelspace
12270 error_swapgs: 12274 error_swapgs:
12271 SWAPGS 12275 SWAPGS
12272@@ -1490,6 +1833,16 @@ ENTRY(nmi) 12276@@ -1490,6 +1838,16 @@ ENTRY(nmi)
12273 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 12277 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
12274 call save_paranoid 12278 call save_paranoid
12275 DEFAULT_FRAME 0 12279 DEFAULT_FRAME 0
@@ -12286,7 +12290,7 @@ diff -urNp linux-3.0.3/arch/x86/kernel/entry_64.S linux-3.0.3/arch/x86/kernel/en
12286 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */ 12290 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
12287 movq %rsp,%rdi 12291 movq %rsp,%rdi
12288 movq $-1,%rsi 12292 movq $-1,%rsi
12289@@ -1500,11 +1853,25 @@ ENTRY(nmi) 12293@@ -1500,11 +1858,25 @@ ENTRY(nmi)
12290 DISABLE_INTERRUPTS(CLBR_NONE) 12294 DISABLE_INTERRUPTS(CLBR_NONE)
12291 testl %ebx,%ebx /* swapgs needed? */ 12295 testl %ebx,%ebx /* swapgs needed? */
12292 jnz nmi_restore 12296 jnz nmi_restore
@@ -35002,7 +35006,18 @@ diff -urNp linux-3.0.3/fs/ceph/dir.c linux-3.0.3/fs/ceph/dir.c
35002 struct ceph_mds_reply_info_parsed *rinfo; 35006 struct ceph_mds_reply_info_parsed *rinfo;
35003diff -urNp linux-3.0.3/fs/cifs/cifs_debug.c linux-3.0.3/fs/cifs/cifs_debug.c 35007diff -urNp linux-3.0.3/fs/cifs/cifs_debug.c linux-3.0.3/fs/cifs/cifs_debug.c
35004--- linux-3.0.3/fs/cifs/cifs_debug.c 2011-07-21 22:17:23.000000000 -0400 35008--- linux-3.0.3/fs/cifs/cifs_debug.c 2011-07-21 22:17:23.000000000 -0400
35005+++ linux-3.0.3/fs/cifs/cifs_debug.c 2011-08-23 21:47:56.000000000 -0400 35009+++ linux-3.0.3/fs/cifs/cifs_debug.c 2011-08-25 17:18:05.000000000 -0400
35010@@ -265,8 +265,8 @@ static ssize_t cifs_stats_proc_write(str
35011
35012 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
35013 #ifdef CONFIG_CIFS_STATS2
35014- atomic_set(&totBufAllocCount, 0);
35015- atomic_set(&totSmBufAllocCount, 0);
35016+ atomic_set_unchecked(&totBufAllocCount, 0);
35017+ atomic_set_unchecked(&totSmBufAllocCount, 0);
35018 #endif /* CONFIG_CIFS_STATS2 */
35019 spin_lock(&cifs_tcp_ses_lock);
35020 list_for_each(tmp1, &cifs_tcp_ses_list) {
35006@@ -279,25 +279,25 @@ static ssize_t cifs_stats_proc_write(str 35021@@ -279,25 +279,25 @@ static ssize_t cifs_stats_proc_write(str
35007 tcon = list_entry(tmp3, 35022 tcon = list_entry(tmp3,
35008 struct cifs_tcon, 35023 struct cifs_tcon,
@@ -35048,6 +35063,17 @@ diff -urNp linux-3.0.3/fs/cifs/cifs_debug.c linux-3.0.3/fs/cifs/cifs_debug.c
35048 } 35063 }
35049 } 35064 }
35050 } 35065 }
35066@@ -327,8 +327,8 @@ static int cifs_stats_proc_show(struct s
35067 smBufAllocCount.counter, cifs_min_small);
35068 #ifdef CONFIG_CIFS_STATS2
35069 seq_printf(m, "Total Large %d Small %d Allocations\n",
35070- atomic_read(&totBufAllocCount),
35071- atomic_read(&totSmBufAllocCount));
35072+ atomic_read_unchecked(&totBufAllocCount),
35073+ atomic_read_unchecked(&totSmBufAllocCount));
35074 #endif /* CONFIG_CIFS_STATS2 */
35075
35076 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
35051@@ -357,41 +357,41 @@ static int cifs_stats_proc_show(struct s 35077@@ -357,41 +357,41 @@ static int cifs_stats_proc_show(struct s
35052 if (tcon->need_reconnect) 35078 if (tcon->need_reconnect)
35053 seq_puts(m, "\tDISCONNECTED "); 35079 seq_puts(m, "\tDISCONNECTED ");
@@ -35110,9 +35136,41 @@ diff -urNp linux-3.0.3/fs/cifs/cifs_debug.c linux-3.0.3/fs/cifs/cifs_debug.c
35110 } 35136 }
35111 } 35137 }
35112 } 35138 }
35139diff -urNp linux-3.0.3/fs/cifs/cifsfs.c linux-3.0.3/fs/cifs/cifsfs.c
35140--- linux-3.0.3/fs/cifs/cifsfs.c 2011-08-23 21:44:40.000000000 -0400
35141+++ linux-3.0.3/fs/cifs/cifsfs.c 2011-08-25 17:18:05.000000000 -0400
35142@@ -994,7 +994,7 @@ cifs_init_request_bufs(void)
35143 cifs_req_cachep = kmem_cache_create("cifs_request",
35144 CIFSMaxBufSize +
35145 MAX_CIFS_HDR_SIZE, 0,
35146- SLAB_HWCACHE_ALIGN, NULL);
35147+ SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
35148 if (cifs_req_cachep == NULL)
35149 return -ENOMEM;
35150
35151@@ -1021,7 +1021,7 @@ cifs_init_request_bufs(void)
35152 efficient to alloc 1 per page off the slab compared to 17K (5page)
35153 alloc of large cifs buffers even when page debugging is on */
35154 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
35155- MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
35156+ MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
35157 NULL);
35158 if (cifs_sm_req_cachep == NULL) {
35159 mempool_destroy(cifs_req_poolp);
35160@@ -1106,8 +1106,8 @@ init_cifs(void)
35161 atomic_set(&bufAllocCount, 0);
35162 atomic_set(&smBufAllocCount, 0);
35163 #ifdef CONFIG_CIFS_STATS2
35164- atomic_set(&totBufAllocCount, 0);
35165- atomic_set(&totSmBufAllocCount, 0);
35166+ atomic_set_unchecked(&totBufAllocCount, 0);
35167+ atomic_set_unchecked(&totSmBufAllocCount, 0);
35168 #endif /* CONFIG_CIFS_STATS2 */
35169
35170 atomic_set(&midCount, 0);
35113diff -urNp linux-3.0.3/fs/cifs/cifsglob.h linux-3.0.3/fs/cifs/cifsglob.h 35171diff -urNp linux-3.0.3/fs/cifs/cifsglob.h linux-3.0.3/fs/cifs/cifsglob.h
35114--- linux-3.0.3/fs/cifs/cifsglob.h 2011-07-21 22:17:23.000000000 -0400 35172--- linux-3.0.3/fs/cifs/cifsglob.h 2011-07-21 22:17:23.000000000 -0400
35115+++ linux-3.0.3/fs/cifs/cifsglob.h 2011-08-23 21:47:56.000000000 -0400 35173+++ linux-3.0.3/fs/cifs/cifsglob.h 2011-08-25 17:18:05.000000000 -0400
35116@@ -381,28 +381,28 @@ struct cifs_tcon { 35174@@ -381,28 +381,28 @@ struct cifs_tcon {
35117 __u16 Flags; /* optional support bits */ 35175 __u16 Flags; /* optional support bits */
35118 enum statusEnum tidStatus; 35176 enum statusEnum tidStatus;
@@ -35173,6 +35231,17 @@ diff -urNp linux-3.0.3/fs/cifs/cifsglob.h linux-3.0.3/fs/cifs/cifsglob.h
35173 35231
35174 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon, 35232 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
35175 unsigned int bytes) 35233 unsigned int bytes)
35234@@ -911,8 +911,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnect
35235 /* Various Debug counters */
35236 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
35237 #ifdef CONFIG_CIFS_STATS2
35238-GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
35239-GLOBAL_EXTERN atomic_t totSmBufAllocCount;
35240+GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
35241+GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
35242 #endif
35243 GLOBAL_EXTERN atomic_t smBufAllocCount;
35244 GLOBAL_EXTERN atomic_t midCount;
35176diff -urNp linux-3.0.3/fs/cifs/link.c linux-3.0.3/fs/cifs/link.c 35245diff -urNp linux-3.0.3/fs/cifs/link.c linux-3.0.3/fs/cifs/link.c
35177--- linux-3.0.3/fs/cifs/link.c 2011-07-21 22:17:23.000000000 -0400 35246--- linux-3.0.3/fs/cifs/link.c 2011-07-21 22:17:23.000000000 -0400
35178+++ linux-3.0.3/fs/cifs/link.c 2011-08-23 21:47:56.000000000 -0400 35247+++ linux-3.0.3/fs/cifs/link.c 2011-08-23 21:47:56.000000000 -0400
@@ -35185,6 +35254,27 @@ diff -urNp linux-3.0.3/fs/cifs/link.c linux-3.0.3/fs/cifs/link.c
35185 if (!IS_ERR(p)) 35254 if (!IS_ERR(p))
35186 kfree(p); 35255 kfree(p);
35187 } 35256 }
35257diff -urNp linux-3.0.3/fs/cifs/misc.c linux-3.0.3/fs/cifs/misc.c
35258--- linux-3.0.3/fs/cifs/misc.c 2011-07-21 22:17:23.000000000 -0400
35259+++ linux-3.0.3/fs/cifs/misc.c 2011-08-25 17:18:05.000000000 -0400
35260@@ -156,7 +156,7 @@ cifs_buf_get(void)
35261 memset(ret_buf, 0, sizeof(struct smb_hdr) + 3);
35262 atomic_inc(&bufAllocCount);
35263 #ifdef CONFIG_CIFS_STATS2
35264- atomic_inc(&totBufAllocCount);
35265+ atomic_inc_unchecked(&totBufAllocCount);
35266 #endif /* CONFIG_CIFS_STATS2 */
35267 }
35268
35269@@ -191,7 +191,7 @@ cifs_small_buf_get(void)
35270 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
35271 atomic_inc(&smBufAllocCount);
35272 #ifdef CONFIG_CIFS_STATS2
35273- atomic_inc(&totSmBufAllocCount);
35274+ atomic_inc_unchecked(&totSmBufAllocCount);
35275 #endif /* CONFIG_CIFS_STATS2 */
35276
35277 }
35188diff -urNp linux-3.0.3/fs/coda/cache.c linux-3.0.3/fs/coda/cache.c 35278diff -urNp linux-3.0.3/fs/coda/cache.c linux-3.0.3/fs/coda/cache.c
35189--- linux-3.0.3/fs/coda/cache.c 2011-07-21 22:17:23.000000000 -0400 35279--- linux-3.0.3/fs/coda/cache.c 2011-07-21 22:17:23.000000000 -0400
35190+++ linux-3.0.3/fs/coda/cache.c 2011-08-23 21:47:56.000000000 -0400 35280+++ linux-3.0.3/fs/coda/cache.c 2011-08-23 21:47:56.000000000 -0400
@@ -35457,7 +35547,7 @@ diff -urNp linux-3.0.3/fs/ecryptfs/miscdev.c linux-3.0.3/fs/ecryptfs/miscdev.c
35457 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size)) 35547 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
35458diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c 35548diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
35459--- linux-3.0.3/fs/exec.c 2011-07-21 22:17:23.000000000 -0400 35549--- linux-3.0.3/fs/exec.c 2011-07-21 22:17:23.000000000 -0400
35460+++ linux-3.0.3/fs/exec.c 2011-08-23 21:48:14.000000000 -0400 35550+++ linux-3.0.3/fs/exec.c 2011-08-25 17:26:58.000000000 -0400
35461@@ -55,12 +55,24 @@ 35551@@ -55,12 +55,24 @@
35462 #include <linux/pipe_fs_i.h> 35552 #include <linux/pipe_fs_i.h>
35463 #include <linux/oom.h> 35553 #include <linux/oom.h>
@@ -35680,7 +35770,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
35680 bprm->unsafe |= LSM_UNSAFE_SHARE; 35770 bprm->unsafe |= LSM_UNSAFE_SHARE;
35681 } else { 35771 } else {
35682 res = -EAGAIN; 35772 res = -EAGAIN;
35683@@ -1428,6 +1445,11 @@ static int do_execve_common(const char * 35773@@ -1428,11 +1445,35 @@ static int do_execve_common(const char *
35684 struct user_arg_ptr envp, 35774 struct user_arg_ptr envp,
35685 struct pt_regs *regs) 35775 struct pt_regs *regs)
35686 { 35776 {
@@ -35692,7 +35782,31 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
35692 struct linux_binprm *bprm; 35782 struct linux_binprm *bprm;
35693 struct file *file; 35783 struct file *file;
35694 struct files_struct *displaced; 35784 struct files_struct *displaced;
35695@@ -1464,6 +1486,23 @@ static int do_execve_common(const char * 35785 bool clear_in_exec;
35786 int retval;
35787+ const struct cred *cred = current_cred();
35788+
35789+ gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
35790+
35791+ /*
35792+ * We move the actual failure in case of RLIMIT_NPROC excess from
35793+ * set*uid() to execve() because too many poorly written programs
35794+ * don't check setuid() return code. Here we additionally recheck
35795+ * whether NPROC limit is still exceeded.
35796+ */
35797+ if ((current->flags & PF_NPROC_EXCEEDED) &&
35798+ atomic_read(&cred->user->processes) > rlimit(RLIMIT_NPROC)) {
35799+ retval = -EAGAIN;
35800+ goto out_ret;
35801+ }
35802+
35803+ /* We're below the limit (still or again), so we don't want to make
35804+ * further execve() calls fail. */
35805+ current->flags &= ~PF_NPROC_EXCEEDED;
35806
35807 retval = unshare_files(&displaced);
35808 if (retval)
35809@@ -1464,6 +1505,16 @@ static int do_execve_common(const char *
35696 bprm->filename = filename; 35810 bprm->filename = filename;
35697 bprm->interp = filename; 35811 bprm->interp = filename;
35698 35812
@@ -35701,13 +35815,6 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
35701+ goto out_file; 35815+ goto out_file;
35702+ } 35816+ }
35703+ 35817+
35704+ gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
35705+
35706+ if (gr_handle_nproc()) {
35707+ retval = -EAGAIN;
35708+ goto out_file;
35709+ }
35710+
35711+ if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) { 35818+ if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
35712+ retval = -EACCES; 35819+ retval = -EACCES;
35713+ goto out_file; 35820+ goto out_file;
@@ -35716,7 +35823,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
35716 retval = bprm_mm_init(bprm); 35823 retval = bprm_mm_init(bprm);
35717 if (retval) 35824 if (retval)
35718 goto out_file; 35825 goto out_file;
35719@@ -1493,9 +1532,40 @@ static int do_execve_common(const char * 35826@@ -1493,9 +1544,40 @@ static int do_execve_common(const char *
35720 if (retval < 0) 35827 if (retval < 0)
35721 goto out; 35828 goto out;
35722 35829
@@ -35758,7 +35865,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
35758 35865
35759 /* execve succeeded */ 35866 /* execve succeeded */
35760 current->fs->in_exec = 0; 35867 current->fs->in_exec = 0;
35761@@ -1506,6 +1576,14 @@ static int do_execve_common(const char * 35868@@ -1506,6 +1588,14 @@ static int do_execve_common(const char *
35762 put_files_struct(displaced); 35869 put_files_struct(displaced);
35763 return retval; 35870 return retval;
35764 35871
@@ -35773,7 +35880,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
35773 out: 35880 out:
35774 if (bprm->mm) { 35881 if (bprm->mm) {
35775 acct_arg_size(bprm, 0); 35882 acct_arg_size(bprm, 0);
35776@@ -1579,7 +1657,7 @@ static int expand_corename(struct core_n 35883@@ -1579,7 +1669,7 @@ static int expand_corename(struct core_n
35777 { 35884 {
35778 char *old_corename = cn->corename; 35885 char *old_corename = cn->corename;
35779 35886
@@ -35782,7 +35889,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
35782 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL); 35889 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
35783 35890
35784 if (!cn->corename) { 35891 if (!cn->corename) {
35785@@ -1667,7 +1745,7 @@ static int format_corename(struct core_n 35892@@ -1667,7 +1757,7 @@ static int format_corename(struct core_n
35786 int pid_in_pattern = 0; 35893 int pid_in_pattern = 0;
35787 int err = 0; 35894 int err = 0;
35788 35895
@@ -35791,7 +35898,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
35791 cn->corename = kmalloc(cn->size, GFP_KERNEL); 35898 cn->corename = kmalloc(cn->size, GFP_KERNEL);
35792 cn->used = 0; 35899 cn->used = 0;
35793 35900
35794@@ -1758,6 +1836,219 @@ out: 35901@@ -1758,6 +1848,219 @@ out:
35795 return ispipe; 35902 return ispipe;
35796 } 35903 }
35797 35904
@@ -36011,7 +36118,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
36011 static int zap_process(struct task_struct *start, int exit_code) 36118 static int zap_process(struct task_struct *start, int exit_code)
36012 { 36119 {
36013 struct task_struct *t; 36120 struct task_struct *t;
36014@@ -1969,17 +2260,17 @@ static void wait_for_dump_helpers(struct 36121@@ -1969,17 +2272,17 @@ static void wait_for_dump_helpers(struct
36015 pipe = file->f_path.dentry->d_inode->i_pipe; 36122 pipe = file->f_path.dentry->d_inode->i_pipe;
36016 36123
36017 pipe_lock(pipe); 36124 pipe_lock(pipe);
@@ -36034,7 +36141,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
36034 pipe_unlock(pipe); 36141 pipe_unlock(pipe);
36035 36142
36036 } 36143 }
36037@@ -2040,7 +2331,7 @@ void do_coredump(long signr, int exit_co 36144@@ -2040,7 +2343,7 @@ void do_coredump(long signr, int exit_co
36038 int retval = 0; 36145 int retval = 0;
36039 int flag = 0; 36146 int flag = 0;
36040 int ispipe; 36147 int ispipe;
@@ -36043,7 +36150,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
36043 struct coredump_params cprm = { 36150 struct coredump_params cprm = {
36044 .signr = signr, 36151 .signr = signr,
36045 .regs = regs, 36152 .regs = regs,
36046@@ -2055,6 +2346,9 @@ void do_coredump(long signr, int exit_co 36153@@ -2055,6 +2358,9 @@ void do_coredump(long signr, int exit_co
36047 36154
36048 audit_core_dumps(signr); 36155 audit_core_dumps(signr);
36049 36156
@@ -36053,7 +36160,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
36053 binfmt = mm->binfmt; 36160 binfmt = mm->binfmt;
36054 if (!binfmt || !binfmt->core_dump) 36161 if (!binfmt || !binfmt->core_dump)
36055 goto fail; 36162 goto fail;
36056@@ -2095,6 +2389,8 @@ void do_coredump(long signr, int exit_co 36163@@ -2095,6 +2401,8 @@ void do_coredump(long signr, int exit_co
36057 goto fail_corename; 36164 goto fail_corename;
36058 } 36165 }
36059 36166
@@ -36062,7 +36169,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
36062 if (ispipe) { 36169 if (ispipe) {
36063 int dump_count; 36170 int dump_count;
36064 char **helper_argv; 36171 char **helper_argv;
36065@@ -2122,7 +2418,7 @@ void do_coredump(long signr, int exit_co 36172@@ -2122,7 +2430,7 @@ void do_coredump(long signr, int exit_co
36066 } 36173 }
36067 cprm.limit = RLIM_INFINITY; 36174 cprm.limit = RLIM_INFINITY;
36068 36175
@@ -36071,7 +36178,7 @@ diff -urNp linux-3.0.3/fs/exec.c linux-3.0.3/fs/exec.c
36071 if (core_pipe_limit && (core_pipe_limit < dump_count)) { 36178 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
36072 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n", 36179 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
36073 task_tgid_vnr(current), current->comm); 36180 task_tgid_vnr(current), current->comm);
36074@@ -2192,7 +2488,7 @@ close_fail: 36181@@ -2192,7 +2500,7 @@ close_fail:
36075 filp_close(cprm.file, NULL); 36182 filp_close(cprm.file, NULL);
36076 fail_dropcount: 36183 fail_dropcount:
36077 if (ispipe) 36184 if (ispipe)
@@ -47792,8 +47899,8 @@ diff -urNp linux-3.0.3/grsecurity/grsec_disabled.c linux-3.0.3/grsecurity/grsec_
47792+#endif 47899+#endif
47793diff -urNp linux-3.0.3/grsecurity/grsec_exec.c linux-3.0.3/grsecurity/grsec_exec.c 47900diff -urNp linux-3.0.3/grsecurity/grsec_exec.c linux-3.0.3/grsecurity/grsec_exec.c
47794--- linux-3.0.3/grsecurity/grsec_exec.c 1969-12-31 19:00:00.000000000 -0500 47901--- linux-3.0.3/grsecurity/grsec_exec.c 1969-12-31 19:00:00.000000000 -0500
47795+++ linux-3.0.3/grsecurity/grsec_exec.c 2011-08-23 21:48:14.000000000 -0400 47902+++ linux-3.0.3/grsecurity/grsec_exec.c 2011-08-25 17:25:59.000000000 -0400
47796@@ -0,0 +1,87 @@ 47903@@ -0,0 +1,72 @@
47797+#include <linux/kernel.h> 47904+#include <linux/kernel.h>
47798+#include <linux/sched.h> 47905+#include <linux/sched.h>
47799+#include <linux/file.h> 47906+#include <linux/file.h>
@@ -47812,21 +47919,6 @@ diff -urNp linux-3.0.3/grsecurity/grsec_exec.c linux-3.0.3/grsecurity/grsec_exec
47812+static DEFINE_MUTEX(gr_exec_arg_mutex); 47919+static DEFINE_MUTEX(gr_exec_arg_mutex);
47813+#endif 47920+#endif
47814+ 47921+
47815+int
47816+gr_handle_nproc(void)
47817+{
47818+#ifdef CONFIG_GRKERNSEC_EXECVE
47819+ const struct cred *cred = current_cred();
47820+ if (grsec_enable_execve && cred->user &&
47821+ (atomic_read(&cred->user->processes) > rlimit(RLIMIT_NPROC)) &&
47822+ !capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE)) {
47823+ gr_log_noargs(GR_DONT_AUDIT, GR_NPROC_MSG);
47824+ return -EAGAIN;
47825+ }
47826+#endif
47827+ return 0;
47828+}
47829+
47830+extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr); 47922+extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
47831+ 47923+
47832+void 47924+void
@@ -47938,8 +48030,8 @@ diff -urNp linux-3.0.3/grsecurity/grsec_fork.c linux-3.0.3/grsecurity/grsec_fork
47938+} 48030+}
47939diff -urNp linux-3.0.3/grsecurity/grsec_init.c linux-3.0.3/grsecurity/grsec_init.c 48031diff -urNp linux-3.0.3/grsecurity/grsec_init.c linux-3.0.3/grsecurity/grsec_init.c
47940--- linux-3.0.3/grsecurity/grsec_init.c 1969-12-31 19:00:00.000000000 -0500 48032--- linux-3.0.3/grsecurity/grsec_init.c 1969-12-31 19:00:00.000000000 -0500
47941+++ linux-3.0.3/grsecurity/grsec_init.c 2011-08-23 21:48:14.000000000 -0400 48033+++ linux-3.0.3/grsecurity/grsec_init.c 2011-08-25 17:25:12.000000000 -0400
47942@@ -0,0 +1,273 @@ 48034@@ -0,0 +1,269 @@
47943+#include <linux/kernel.h> 48035+#include <linux/kernel.h>
47944+#include <linux/sched.h> 48036+#include <linux/sched.h>
47945+#include <linux/mm.h> 48037+#include <linux/mm.h>
@@ -47954,7 +48046,6 @@ diff -urNp linux-3.0.3/grsecurity/grsec_init.c linux-3.0.3/grsecurity/grsec_init
47954+int grsec_enable_dmesg; 48046+int grsec_enable_dmesg;
47955+int grsec_enable_harden_ptrace; 48047+int grsec_enable_harden_ptrace;
47956+int grsec_enable_fifo; 48048+int grsec_enable_fifo;
47957+int grsec_enable_execve;
47958+int grsec_enable_execlog; 48049+int grsec_enable_execlog;
47959+int grsec_enable_signal; 48050+int grsec_enable_signal;
47960+int grsec_enable_forkfail; 48051+int grsec_enable_forkfail;
@@ -48127,9 +48218,6 @@ diff -urNp linux-3.0.3/grsecurity/grsec_init.c linux-3.0.3/grsecurity/grsec_init
48127+#ifdef CONFIG_GRKERNSEC_FIFO 48218+#ifdef CONFIG_GRKERNSEC_FIFO
48128+ grsec_enable_fifo = 1; 48219+ grsec_enable_fifo = 1;
48129+#endif 48220+#endif
48130+#ifdef CONFIG_GRKERNSEC_EXECVE
48131+ grsec_enable_execve = 1;
48132+#endif
48133+#ifdef CONFIG_GRKERNSEC_EXECLOG 48221+#ifdef CONFIG_GRKERNSEC_EXECLOG
48134+ grsec_enable_execlog = 1; 48222+ grsec_enable_execlog = 1;
48135+#endif 48223+#endif
@@ -49195,8 +49283,8 @@ diff -urNp linux-3.0.3/grsecurity/grsec_sock.c linux-3.0.3/grsecurity/grsec_sock
49195+} 49283+}
49196diff -urNp linux-3.0.3/grsecurity/grsec_sysctl.c linux-3.0.3/grsecurity/grsec_sysctl.c 49284diff -urNp linux-3.0.3/grsecurity/grsec_sysctl.c linux-3.0.3/grsecurity/grsec_sysctl.c
49197--- linux-3.0.3/grsecurity/grsec_sysctl.c 1969-12-31 19:00:00.000000000 -0500 49285--- linux-3.0.3/grsecurity/grsec_sysctl.c 1969-12-31 19:00:00.000000000 -0500
49198+++ linux-3.0.3/grsecurity/grsec_sysctl.c 2011-08-23 21:48:14.000000000 -0400 49286+++ linux-3.0.3/grsecurity/grsec_sysctl.c 2011-08-25 17:26:15.000000000 -0400
49199@@ -0,0 +1,442 @@ 49287@@ -0,0 +1,433 @@
49200+#include <linux/kernel.h> 49288+#include <linux/kernel.h>
49201+#include <linux/sched.h> 49289+#include <linux/sched.h>
49202+#include <linux/sysctl.h> 49290+#include <linux/sysctl.h>
@@ -49260,15 +49348,6 @@ diff -urNp linux-3.0.3/grsecurity/grsec_sysctl.c linux-3.0.3/grsecurity/grsec_sy
49260+ .proc_handler = &proc_dointvec, 49348+ .proc_handler = &proc_dointvec,
49261+ }, 49349+ },
49262+#endif 49350+#endif
49263+#ifdef CONFIG_GRKERNSEC_EXECVE
49264+ {
49265+ .procname = "execve_limiting",
49266+ .data = &grsec_enable_execve,
49267+ .maxlen = sizeof(int),
49268+ .mode = 0600,
49269+ .proc_handler = &proc_dointvec,
49270+ },
49271+#endif
49272+#ifdef CONFIG_GRKERNSEC_BLACKHOLE 49351+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
49273+ { 49352+ {
49274+ .procname = "ip_blackhole", 49353+ .procname = "ip_blackhole",
@@ -49769,8 +49848,8 @@ diff -urNp linux-3.0.3/grsecurity/grsum.c linux-3.0.3/grsecurity/grsum.c
49769+} 49848+}
49770diff -urNp linux-3.0.3/grsecurity/Kconfig linux-3.0.3/grsecurity/Kconfig 49849diff -urNp linux-3.0.3/grsecurity/Kconfig linux-3.0.3/grsecurity/Kconfig
49771--- linux-3.0.3/grsecurity/Kconfig 1969-12-31 19:00:00.000000000 -0500 49850--- linux-3.0.3/grsecurity/Kconfig 1969-12-31 19:00:00.000000000 -0500
49772+++ linux-3.0.3/grsecurity/Kconfig 2011-08-23 21:48:14.000000000 -0400 49851+++ linux-3.0.3/grsecurity/Kconfig 2011-08-25 17:25:34.000000000 -0400
49773@@ -0,0 +1,1050 @@ 49852@@ -0,0 +1,1038 @@
49774+# 49853+#
49775+# grecurity configuration 49854+# grecurity configuration
49776+# 49855+#
@@ -49797,7 +49876,6 @@ diff -urNp linux-3.0.3/grsecurity/Kconfig linux-3.0.3/grsecurity/Kconfig
49797+ bool "Low" 49876+ bool "Low"
49798+ select GRKERNSEC_LINK 49877+ select GRKERNSEC_LINK
49799+ select GRKERNSEC_FIFO 49878+ select GRKERNSEC_FIFO
49800+ select GRKERNSEC_EXECVE
49801+ select GRKERNSEC_RANDNET 49879+ select GRKERNSEC_RANDNET
49802+ select GRKERNSEC_DMESG 49880+ select GRKERNSEC_DMESG
49803+ select GRKERNSEC_CHROOT 49881+ select GRKERNSEC_CHROOT
@@ -49814,7 +49892,6 @@ diff -urNp linux-3.0.3/grsecurity/Kconfig linux-3.0.3/grsecurity/Kconfig
49814+ 49892+
49815+ - Linking restrictions 49893+ - Linking restrictions
49816+ - FIFO restrictions 49894+ - FIFO restrictions
49817+ - Enforcing RLIMIT_NPROC on execve
49818+ - Restricted dmesg 49895+ - Restricted dmesg
49819+ - Enforced chdir("/") on chroot 49896+ - Enforced chdir("/") on chroot
49820+ - Runtime module disabling 49897+ - Runtime module disabling
@@ -49830,7 +49907,6 @@ diff -urNp linux-3.0.3/grsecurity/Kconfig linux-3.0.3/grsecurity/Kconfig
49830+ select GRKERNSEC_CHROOT_SYSCTL 49907+ select GRKERNSEC_CHROOT_SYSCTL
49831+ select GRKERNSEC_LINK 49908+ select GRKERNSEC_LINK
49832+ select GRKERNSEC_FIFO 49909+ select GRKERNSEC_FIFO
49833+ select GRKERNSEC_EXECVE
49834+ select GRKERNSEC_DMESG 49910+ select GRKERNSEC_DMESG
49835+ select GRKERNSEC_RANDNET 49911+ select GRKERNSEC_RANDNET
49836+ select GRKERNSEC_FORKFAIL 49912+ select GRKERNSEC_FORKFAIL
@@ -49880,7 +49956,6 @@ diff -urNp linux-3.0.3/grsecurity/Kconfig linux-3.0.3/grsecurity/Kconfig
49880+ bool "High" 49956+ bool "High"
49881+ select GRKERNSEC_LINK 49957+ select GRKERNSEC_LINK
49882+ select GRKERNSEC_FIFO 49958+ select GRKERNSEC_FIFO
49883+ select GRKERNSEC_EXECVE
49884+ select GRKERNSEC_DMESG 49959+ select GRKERNSEC_DMESG
49885+ select GRKERNSEC_FORKFAIL 49960+ select GRKERNSEC_FORKFAIL
49886+ select GRKERNSEC_TIME 49961+ select GRKERNSEC_TIME
@@ -50548,14 +50623,6 @@ diff -urNp linux-3.0.3/grsecurity/Kconfig linux-3.0.3/grsecurity/Kconfig
50548+menu "Executable Protections" 50623+menu "Executable Protections"
50549+depends on GRKERNSEC 50624+depends on GRKERNSEC
50550+ 50625+
50551+config GRKERNSEC_EXECVE
50552+ bool "Enforce RLIMIT_NPROC on execs"
50553+ help
50554+ If you say Y here, users with a resource limit on processes will
50555+ have the value checked during execve() calls. The current system
50556+ only checks the system limit during fork() calls. If the sysctl option
50557+ is enabled, a sysctl option with name "execve_limiting" is created.
50558+
50559+config GRKERNSEC_DMESG 50626+config GRKERNSEC_DMESG
50560+ bool "Dmesg(8) restriction" 50627+ bool "Dmesg(8) restriction"
50561+ help 50628+ help
@@ -52631,8 +52698,8 @@ diff -urNp linux-3.0.3/include/linux/grinternal.h linux-3.0.3/include/linux/grin
52631+#endif 52698+#endif
52632diff -urNp linux-3.0.3/include/linux/grmsg.h linux-3.0.3/include/linux/grmsg.h 52699diff -urNp linux-3.0.3/include/linux/grmsg.h linux-3.0.3/include/linux/grmsg.h
52633--- linux-3.0.3/include/linux/grmsg.h 1969-12-31 19:00:00.000000000 -0500 52700--- linux-3.0.3/include/linux/grmsg.h 1969-12-31 19:00:00.000000000 -0500
52634+++ linux-3.0.3/include/linux/grmsg.h 2011-08-23 21:48:14.000000000 -0400 52701+++ linux-3.0.3/include/linux/grmsg.h 2011-08-25 17:27:26.000000000 -0400
52635@@ -0,0 +1,108 @@ 52702@@ -0,0 +1,107 @@
52636+#define DEFAULTSECMSG "%.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u, parent %.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u" 52703+#define DEFAULTSECMSG "%.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u, parent %.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u"
52637+#define GR_ACL_PROCACCT_MSG "%.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u run time:[%ud %uh %um %us] cpu time:[%ud %uh %um %us] %s with exit code %ld, parent %.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u" 52704+#define GR_ACL_PROCACCT_MSG "%.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u run time:[%ud %uh %um %us] cpu time:[%ud %uh %um %us] %s with exit code %ld, parent %.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u"
52638+#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by " 52705+#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
@@ -52666,7 +52733,6 @@ diff -urNp linux-3.0.3/include/linux/grmsg.h linux-3.0.3/include/linux/grmsg.h
52666+#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by " 52733+#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
52667+#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by " 52734+#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
52668+#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by " 52735+#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
52669+#define GR_NPROC_MSG "denied overstep of process limit by "
52670+#define GR_EXEC_ACL_MSG "%s execution of %.950s by " 52736+#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
52671+#define GR_EXEC_TPE_MSG "denied untrusted exec of %.950s by " 52737+#define GR_EXEC_TPE_MSG "denied untrusted exec of %.950s by "
52672+#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds" 52738+#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
@@ -52743,8 +52809,8 @@ diff -urNp linux-3.0.3/include/linux/grmsg.h linux-3.0.3/include/linux/grmsg.h
52743+#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by " 52809+#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
52744diff -urNp linux-3.0.3/include/linux/grsecurity.h linux-3.0.3/include/linux/grsecurity.h 52810diff -urNp linux-3.0.3/include/linux/grsecurity.h linux-3.0.3/include/linux/grsecurity.h
52745--- linux-3.0.3/include/linux/grsecurity.h 1969-12-31 19:00:00.000000000 -0500 52811--- linux-3.0.3/include/linux/grsecurity.h 1969-12-31 19:00:00.000000000 -0500
52746+++ linux-3.0.3/include/linux/grsecurity.h 2011-08-23 21:48:14.000000000 -0400 52812+++ linux-3.0.3/include/linux/grsecurity.h 2011-08-25 17:27:36.000000000 -0400
52747@@ -0,0 +1,228 @@ 52813@@ -0,0 +1,227 @@
52748+#ifndef GR_SECURITY_H 52814+#ifndef GR_SECURITY_H
52749+#define GR_SECURITY_H 52815+#define GR_SECURITY_H
52750+#include <linux/fs.h> 52816+#include <linux/fs.h>
@@ -52822,7 +52888,6 @@ diff -urNp linux-3.0.3/include/linux/grsecurity.h linux-3.0.3/include/linux/grse
52822+int gr_handle_chroot_unix(const pid_t pid); 52888+int gr_handle_chroot_unix(const pid_t pid);
52823+ 52889+
52824+int gr_handle_rawio(const struct inode *inode); 52890+int gr_handle_rawio(const struct inode *inode);
52825+int gr_handle_nproc(void);
52826+ 52891+
52827+void gr_handle_ioperm(void); 52892+void gr_handle_ioperm(void);
52828+void gr_handle_iopl(void); 52893+void gr_handle_iopl(void);
@@ -53970,7 +54035,7 @@ diff -urNp linux-3.0.3/include/linux/rmap.h linux-3.0.3/include/linux/rmap.h
53970 static inline void anon_vma_merge(struct vm_area_struct *vma, 54035 static inline void anon_vma_merge(struct vm_area_struct *vma,
53971diff -urNp linux-3.0.3/include/linux/sched.h linux-3.0.3/include/linux/sched.h 54036diff -urNp linux-3.0.3/include/linux/sched.h linux-3.0.3/include/linux/sched.h
53972--- linux-3.0.3/include/linux/sched.h 2011-07-21 22:17:23.000000000 -0400 54037--- linux-3.0.3/include/linux/sched.h 2011-07-21 22:17:23.000000000 -0400
53973+++ linux-3.0.3/include/linux/sched.h 2011-08-23 21:48:14.000000000 -0400 54038+++ linux-3.0.3/include/linux/sched.h 2011-08-25 17:22:27.000000000 -0400
53974@@ -100,6 +100,7 @@ struct bio_list; 54039@@ -100,6 +100,7 @@ struct bio_list;
53975 struct fs_struct; 54040 struct fs_struct;
53976 struct perf_event_context; 54041 struct perf_event_context;
@@ -54157,7 +54222,15 @@ diff -urNp linux-3.0.3/include/linux/sched.h linux-3.0.3/include/linux/sched.h
54157 /* Future-safe accessor for struct task_struct's cpus_allowed. */ 54222 /* Future-safe accessor for struct task_struct's cpus_allowed. */
54158 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed) 54223 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
54159 54224
54160@@ -2056,7 +2148,9 @@ void yield(void); 54225@@ -1768,6 +1860,7 @@ extern void thread_group_times(struct ta
54226 #define PF_DUMPCORE 0x00000200 /* dumped core */
54227 #define PF_SIGNALED 0x00000400 /* killed by a signal */
54228 #define PF_MEMALLOC 0x00000800 /* Allocating memory */
54229+#define PF_NPROC_EXCEEDED 0x00001000 /* set_user noticed that RLIMIT_NPROC was exceeded */
54230 #define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */
54231 #define PF_FREEZING 0x00004000 /* freeze in progress. do not account to load */
54232 #define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */
54233@@ -2056,7 +2149,9 @@ void yield(void);
54161 extern struct exec_domain default_exec_domain; 54234 extern struct exec_domain default_exec_domain;
54162 54235
54163 union thread_union { 54236 union thread_union {
@@ -54167,7 +54240,7 @@ diff -urNp linux-3.0.3/include/linux/sched.h linux-3.0.3/include/linux/sched.h
54167 unsigned long stack[THREAD_SIZE/sizeof(long)]; 54240 unsigned long stack[THREAD_SIZE/sizeof(long)];
54168 }; 54241 };
54169 54242
54170@@ -2089,6 +2183,7 @@ extern struct pid_namespace init_pid_ns; 54243@@ -2089,6 +2184,7 @@ extern struct pid_namespace init_pid_ns;
54171 */ 54244 */
54172 54245
54173 extern struct task_struct *find_task_by_vpid(pid_t nr); 54246 extern struct task_struct *find_task_by_vpid(pid_t nr);
@@ -54175,7 +54248,7 @@ diff -urNp linux-3.0.3/include/linux/sched.h linux-3.0.3/include/linux/sched.h
54175 extern struct task_struct *find_task_by_pid_ns(pid_t nr, 54248 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
54176 struct pid_namespace *ns); 54249 struct pid_namespace *ns);
54177 54250
54178@@ -2225,7 +2320,7 @@ extern void __cleanup_sighand(struct sig 54251@@ -2225,7 +2321,7 @@ extern void __cleanup_sighand(struct sig
54179 extern void exit_itimers(struct signal_struct *); 54252 extern void exit_itimers(struct signal_struct *);
54180 extern void flush_itimer_signals(void); 54253 extern void flush_itimer_signals(void);
54181 54254
@@ -54184,7 +54257,7 @@ diff -urNp linux-3.0.3/include/linux/sched.h linux-3.0.3/include/linux/sched.h
54184 54257
54185 extern void daemonize(const char *, ...); 54258 extern void daemonize(const char *, ...);
54186 extern int allow_signal(int); 54259 extern int allow_signal(int);
54187@@ -2393,13 +2488,17 @@ static inline unsigned long *end_of_stac 54260@@ -2393,13 +2489,17 @@ static inline unsigned long *end_of_stac
54188 54261
54189 #endif 54262 #endif
54190 54263
@@ -56173,7 +56246,7 @@ diff -urNp linux-3.0.3/kernel/configs.c linux-3.0.3/kernel/configs.c
56173 56246
56174diff -urNp linux-3.0.3/kernel/cred.c linux-3.0.3/kernel/cred.c 56247diff -urNp linux-3.0.3/kernel/cred.c linux-3.0.3/kernel/cred.c
56175--- linux-3.0.3/kernel/cred.c 2011-07-21 22:17:23.000000000 -0400 56248--- linux-3.0.3/kernel/cred.c 2011-07-21 22:17:23.000000000 -0400
56176+++ linux-3.0.3/kernel/cred.c 2011-08-23 21:48:14.000000000 -0400 56249+++ linux-3.0.3/kernel/cred.c 2011-08-25 17:23:03.000000000 -0400
56177@@ -158,6 +158,8 @@ static void put_cred_rcu(struct rcu_head 56250@@ -158,6 +158,8 @@ static void put_cred_rcu(struct rcu_head
56178 */ 56251 */
56179 void __put_cred(struct cred *cred) 56252 void __put_cred(struct cred *cred)
@@ -56255,7 +56328,20 @@ diff -urNp linux-3.0.3/kernel/cred.c linux-3.0.3/kernel/cred.c
56255 /* dumpability changes */ 56328 /* dumpability changes */
56256 if (old->euid != new->euid || 56329 if (old->euid != new->euid ||
56257 old->egid != new->egid || 56330 old->egid != new->egid ||
56258@@ -551,6 +569,8 @@ EXPORT_SYMBOL(commit_creds); 56331@@ -508,10 +526,8 @@ int commit_creds(struct cred *new)
56332 key_fsgid_changed(task);
56333
56334 /* do it
56335- * - What if a process setreuid()'s and this brings the
56336- * new uid over his NPROC rlimit? We can check this now
56337- * cheaply with the new uid cache, so if it matters
56338- * we should be checking for it. -DaveM
56339+ * RLIMIT_NPROC limits on user->processes have already been checked
56340+ * in set_user().
56341 */
56342 alter_cred_subscribers(new, 2);
56343 if (new->user != old->user)
56344@@ -551,6 +567,8 @@ EXPORT_SYMBOL(commit_creds);
56259 */ 56345 */
56260 void abort_creds(struct cred *new) 56346 void abort_creds(struct cred *new)
56261 { 56347 {
@@ -56264,7 +56350,7 @@ diff -urNp linux-3.0.3/kernel/cred.c linux-3.0.3/kernel/cred.c
56264 kdebug("abort_creds(%p{%d,%d})", new, 56350 kdebug("abort_creds(%p{%d,%d})", new,
56265 atomic_read(&new->usage), 56351 atomic_read(&new->usage),
56266 read_cred_subscribers(new)); 56352 read_cred_subscribers(new));
56267@@ -574,6 +594,8 @@ const struct cred *override_creds(const 56353@@ -574,6 +592,8 @@ const struct cred *override_creds(const
56268 { 56354 {
56269 const struct cred *old = current->cred; 56355 const struct cred *old = current->cred;
56270 56356
@@ -56273,7 +56359,7 @@ diff -urNp linux-3.0.3/kernel/cred.c linux-3.0.3/kernel/cred.c
56273 kdebug("override_creds(%p{%d,%d})", new, 56359 kdebug("override_creds(%p{%d,%d})", new,
56274 atomic_read(&new->usage), 56360 atomic_read(&new->usage),
56275 read_cred_subscribers(new)); 56361 read_cred_subscribers(new));
56276@@ -603,6 +625,8 @@ void revert_creds(const struct cred *old 56362@@ -603,6 +623,8 @@ void revert_creds(const struct cred *old
56277 { 56363 {
56278 const struct cred *override = current->cred; 56364 const struct cred *override = current->cred;
56279 56365
@@ -56282,7 +56368,7 @@ diff -urNp linux-3.0.3/kernel/cred.c linux-3.0.3/kernel/cred.c
56282 kdebug("revert_creds(%p{%d,%d})", old, 56368 kdebug("revert_creds(%p{%d,%d})", old,
56283 atomic_read(&old->usage), 56369 atomic_read(&old->usage),
56284 read_cred_subscribers(old)); 56370 read_cred_subscribers(old));
56285@@ -649,6 +673,8 @@ struct cred *prepare_kernel_cred(struct 56371@@ -649,6 +671,8 @@ struct cred *prepare_kernel_cred(struct
56286 const struct cred *old; 56372 const struct cred *old;
56287 struct cred *new; 56373 struct cred *new;
56288 56374
@@ -56291,7 +56377,7 @@ diff -urNp linux-3.0.3/kernel/cred.c linux-3.0.3/kernel/cred.c
56291 new = kmem_cache_alloc(cred_jar, GFP_KERNEL); 56377 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
56292 if (!new) 56378 if (!new)
56293 return NULL; 56379 return NULL;
56294@@ -703,6 +729,8 @@ EXPORT_SYMBOL(prepare_kernel_cred); 56380@@ -703,6 +727,8 @@ EXPORT_SYMBOL(prepare_kernel_cred);
56295 */ 56381 */
56296 int set_security_override(struct cred *new, u32 secid) 56382 int set_security_override(struct cred *new, u32 secid)
56297 { 56383 {
@@ -56300,7 +56386,7 @@ diff -urNp linux-3.0.3/kernel/cred.c linux-3.0.3/kernel/cred.c
56300 return security_kernel_act_as(new, secid); 56386 return security_kernel_act_as(new, secid);
56301 } 56387 }
56302 EXPORT_SYMBOL(set_security_override); 56388 EXPORT_SYMBOL(set_security_override);
56303@@ -722,6 +750,8 @@ int set_security_override_from_ctx(struc 56389@@ -722,6 +748,8 @@ int set_security_override_from_ctx(struc
56304 u32 secid; 56390 u32 secid;
56305 int ret; 56391 int ret;
56306 56392
@@ -56594,7 +56680,7 @@ diff -urNp linux-3.0.3/kernel/exit.c linux-3.0.3/kernel/exit.c
56594 if (group_dead) 56680 if (group_dead)
56595diff -urNp linux-3.0.3/kernel/fork.c linux-3.0.3/kernel/fork.c 56681diff -urNp linux-3.0.3/kernel/fork.c linux-3.0.3/kernel/fork.c
56596--- linux-3.0.3/kernel/fork.c 2011-07-21 22:17:23.000000000 -0400 56682--- linux-3.0.3/kernel/fork.c 2011-07-21 22:17:23.000000000 -0400
56597+++ linux-3.0.3/kernel/fork.c 2011-08-23 21:48:14.000000000 -0400 56683+++ linux-3.0.3/kernel/fork.c 2011-08-25 17:23:36.000000000 -0400
56598@@ -286,7 +286,7 @@ static struct task_struct *dup_task_stru 56684@@ -286,7 +286,7 @@ static struct task_struct *dup_task_stru
56599 *stackend = STACK_END_MAGIC; /* for overflow detection */ 56685 *stackend = STACK_END_MAGIC; /* for overflow detection */
56600 56686
@@ -56827,7 +56913,7 @@ diff -urNp linux-3.0.3/kernel/fork.c linux-3.0.3/kernel/fork.c
56827 return 0; 56913 return 0;
56828 } 56914 }
56829 56915
56830@@ -1104,10 +1142,13 @@ static struct task_struct *copy_process( 56916@@ -1104,12 +1142,16 @@ static struct task_struct *copy_process(
56831 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled); 56917 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
56832 #endif 56918 #endif
56833 retval = -EAGAIN; 56919 retval = -EAGAIN;
@@ -56842,8 +56928,11 @@ diff -urNp linux-3.0.3/kernel/fork.c linux-3.0.3/kernel/fork.c
56842+ !capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE)) 56928+ !capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE))
56843 goto bad_fork_free; 56929 goto bad_fork_free;
56844 } 56930 }
56931+ current->flags &= ~PF_NPROC_EXCEEDED;
56845 56932
56846@@ -1250,6 +1291,8 @@ static struct task_struct *copy_process( 56933 retval = copy_creds(p, clone_flags);
56934 if (retval < 0)
56935@@ -1250,6 +1292,8 @@ static struct task_struct *copy_process(
56847 if (clone_flags & CLONE_THREAD) 56936 if (clone_flags & CLONE_THREAD)
56848 p->tgid = current->tgid; 56937 p->tgid = current->tgid;
56849 56938
@@ -56852,7 +56941,7 @@ diff -urNp linux-3.0.3/kernel/fork.c linux-3.0.3/kernel/fork.c
56852 p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL; 56941 p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL;
56853 /* 56942 /*
56854 * Clear TID on mm_release()? 56943 * Clear TID on mm_release()?
56855@@ -1414,6 +1457,8 @@ bad_fork_cleanup_count: 56944@@ -1414,6 +1458,8 @@ bad_fork_cleanup_count:
56856 bad_fork_free: 56945 bad_fork_free:
56857 free_task(p); 56946 free_task(p);
56858 fork_out: 56947 fork_out:
@@ -56861,7 +56950,7 @@ diff -urNp linux-3.0.3/kernel/fork.c linux-3.0.3/kernel/fork.c
56861 return ERR_PTR(retval); 56950 return ERR_PTR(retval);
56862 } 56951 }
56863 56952
56864@@ -1502,6 +1547,8 @@ long do_fork(unsigned long clone_flags, 56953@@ -1502,6 +1548,8 @@ long do_fork(unsigned long clone_flags,
56865 if (clone_flags & CLONE_PARENT_SETTID) 56954 if (clone_flags & CLONE_PARENT_SETTID)
56866 put_user(nr, parent_tidptr); 56955 put_user(nr, parent_tidptr);
56867 56956
@@ -56870,7 +56959,7 @@ diff -urNp linux-3.0.3/kernel/fork.c linux-3.0.3/kernel/fork.c
56870 if (clone_flags & CLONE_VFORK) { 56959 if (clone_flags & CLONE_VFORK) {
56871 p->vfork_done = &vfork; 56960 p->vfork_done = &vfork;
56872 init_completion(&vfork); 56961 init_completion(&vfork);
56873@@ -1610,7 +1657,7 @@ static int unshare_fs(unsigned long unsh 56962@@ -1610,7 +1658,7 @@ static int unshare_fs(unsigned long unsh
56874 return 0; 56963 return 0;
56875 56964
56876 /* don't need lock here; in the worst case we'll do useless copy */ 56965 /* don't need lock here; in the worst case we'll do useless copy */
@@ -56879,7 +56968,7 @@ diff -urNp linux-3.0.3/kernel/fork.c linux-3.0.3/kernel/fork.c
56879 return 0; 56968 return 0;
56880 56969
56881 *new_fsp = copy_fs_struct(fs); 56970 *new_fsp = copy_fs_struct(fs);
56882@@ -1697,7 +1744,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, 56971@@ -1697,7 +1745,8 @@ SYSCALL_DEFINE1(unshare, unsigned long,
56883 fs = current->fs; 56972 fs = current->fs;
56884 spin_lock(&fs->lock); 56973 spin_lock(&fs->lock);
56885 current->fs = new_fs; 56974 current->fs = new_fs;
@@ -59381,7 +59470,7 @@ diff -urNp linux-3.0.3/kernel/softirq.c linux-3.0.3/kernel/softirq.c
59381 59470
59382diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c 59471diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c
59383--- linux-3.0.3/kernel/sys.c 2011-07-21 22:17:23.000000000 -0400 59472--- linux-3.0.3/kernel/sys.c 2011-07-21 22:17:23.000000000 -0400
59384+++ linux-3.0.3/kernel/sys.c 2011-08-23 21:48:14.000000000 -0400 59473+++ linux-3.0.3/kernel/sys.c 2011-08-25 17:24:58.000000000 -0400
59385@@ -154,6 +154,12 @@ static int set_one_prio(struct task_stru 59474@@ -154,6 +154,12 @@ static int set_one_prio(struct task_stru
59386 error = -EACCES; 59475 error = -EACCES;
59387 goto out; 59476 goto out;
@@ -59416,7 +59505,30 @@ diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c
59416 if (nsown_capable(CAP_SETGID)) 59505 if (nsown_capable(CAP_SETGID))
59417 new->gid = new->egid = new->sgid = new->fsgid = gid; 59506 new->gid = new->egid = new->sgid = new->fsgid = gid;
59418 else if (gid == old->gid || gid == old->sgid) 59507 else if (gid == old->gid || gid == old->sgid)
59419@@ -646,6 +659,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, u 59508@@ -591,11 +604,18 @@ static int set_user(struct cred *new)
59509 if (!new_user)
59510 return -EAGAIN;
59511
59512+ /*
59513+ * We don't fail in case of NPROC limit excess here because too many
59514+ * poorly written programs don't check set*uid() return code, assuming
59515+ * it never fails if called by root. We may still enforce NPROC limit
59516+ * for programs doing set*uid()+execve() by harmlessly deferring the
59517+ * failure to the execve() stage.
59518+ */
59519 if (atomic_read(&new_user->processes) >= rlimit(RLIMIT_NPROC) &&
59520- new_user != INIT_USER) {
59521- free_uid(new_user);
59522- return -EAGAIN;
59523- }
59524+ new_user != INIT_USER)
59525+ current->flags |= PF_NPROC_EXCEEDED;
59526+ else
59527+ current->flags &= ~PF_NPROC_EXCEEDED;
59528
59529 free_uid(new->user);
59530 new->user = new_user;
59531@@ -646,6 +666,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, u
59420 goto error; 59532 goto error;
59421 } 59533 }
59422 59534
@@ -59426,7 +59538,7 @@ diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c
59426 if (new->uid != old->uid) { 59538 if (new->uid != old->uid) {
59427 retval = set_user(new); 59539 retval = set_user(new);
59428 if (retval < 0) 59540 if (retval < 0)
59429@@ -690,6 +706,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid) 59541@@ -690,6 +713,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
59430 old = current_cred(); 59542 old = current_cred();
59431 59543
59432 retval = -EPERM; 59544 retval = -EPERM;
@@ -59439,7 +59551,7 @@ diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c
59439 if (nsown_capable(CAP_SETUID)) { 59551 if (nsown_capable(CAP_SETUID)) {
59440 new->suid = new->uid = uid; 59552 new->suid = new->uid = uid;
59441 if (uid != old->uid) { 59553 if (uid != old->uid) {
59442@@ -744,6 +766,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, 59554@@ -744,6 +773,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid,
59443 goto error; 59555 goto error;
59444 } 59556 }
59445 59557
@@ -59449,7 +59561,7 @@ diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c
59449 if (ruid != (uid_t) -1) { 59561 if (ruid != (uid_t) -1) {
59450 new->uid = ruid; 59562 new->uid = ruid;
59451 if (ruid != old->uid) { 59563 if (ruid != old->uid) {
59452@@ -808,6 +833,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, 59564@@ -808,6 +840,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid,
59453 goto error; 59565 goto error;
59454 } 59566 }
59455 59567
@@ -59459,7 +59571,7 @@ diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c
59459 if (rgid != (gid_t) -1) 59571 if (rgid != (gid_t) -1)
59460 new->gid = rgid; 59572 new->gid = rgid;
59461 if (egid != (gid_t) -1) 59573 if (egid != (gid_t) -1)
59462@@ -854,6 +882,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid) 59574@@ -854,6 +889,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
59463 old = current_cred(); 59575 old = current_cred();
59464 old_fsuid = old->fsuid; 59576 old_fsuid = old->fsuid;
59465 59577
@@ -59469,7 +59581,7 @@ diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c
59469 if (uid == old->uid || uid == old->euid || 59581 if (uid == old->uid || uid == old->euid ||
59470 uid == old->suid || uid == old->fsuid || 59582 uid == old->suid || uid == old->fsuid ||
59471 nsown_capable(CAP_SETUID)) { 59583 nsown_capable(CAP_SETUID)) {
59472@@ -864,6 +895,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid) 59584@@ -864,6 +902,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
59473 } 59585 }
59474 } 59586 }
59475 59587
@@ -59477,7 +59589,7 @@ diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c
59477 abort_creds(new); 59589 abort_creds(new);
59478 return old_fsuid; 59590 return old_fsuid;
59479 59591
59480@@ -890,12 +922,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid) 59592@@ -890,12 +929,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
59481 if (gid == old->gid || gid == old->egid || 59593 if (gid == old->gid || gid == old->egid ||
59482 gid == old->sgid || gid == old->fsgid || 59594 gid == old->sgid || gid == old->fsgid ||
59483 nsown_capable(CAP_SETGID)) { 59595 nsown_capable(CAP_SETGID)) {
@@ -59494,7 +59606,7 @@ diff -urNp linux-3.0.3/kernel/sys.c linux-3.0.3/kernel/sys.c
59494 abort_creds(new); 59606 abort_creds(new);
59495 return old_fsgid; 59607 return old_fsgid;
59496 59608
59497@@ -1642,7 +1678,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsi 59609@@ -1642,7 +1685,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsi
59498 error = get_dumpable(me->mm); 59610 error = get_dumpable(me->mm);
59499 break; 59611 break;
59500 case PR_SET_DUMPABLE: 59612 case PR_SET_DUMPABLE: