From b17295e646562a2122ce84c1e55c9ae66fb6ae50 Mon Sep 17 00:00:00 2001 From: Sebastian Ott Date: Wed, 12 Jan 2011 09:55:10 +0100 Subject: [PATCH 01/13] [S390] cio: path_event overindication after resume While resuming report any found paths as new to the device drivers. Signed-off-by: Sebastian Ott Signed-off-by: Martin Schwidefsky --- drivers/s390/cio/device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index e8391b89eff4..b7eaff9ca19e 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -1835,6 +1835,7 @@ static void __ccw_device_pm_restore(struct ccw_device *cdev) * available again. Kick re-detection. */ cdev->private->flags.resuming = 1; + cdev->private->path_new_mask = LPM_ANYPATH; css_schedule_eval(sch->schid); spin_unlock_irq(sch->lock); css_complete_work(); From 7a63fa1a85d75756368d9c86fff5c1b193de991c Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Wed, 12 Jan 2011 09:55:21 +0100 Subject: [PATCH 02/13] [S390] Update default configuration Signed-off-by: Martin Schwidefsky --- arch/s390/defconfig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/s390/defconfig b/arch/s390/defconfig index d79697157ac0..29c82c640a88 100644 --- a/arch/s390/defconfig +++ b/arch/s390/defconfig @@ -5,10 +5,21 @@ CONFIG_AUDIT=y CONFIG_RCU_TRACE=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y +CONFIG_CGROUPS=y +CONFIG_CPUSETS=y +CONFIG_CGROUP_CPUACCT=y +CONFIG_RESOURCE_COUNTERS=y +CONFIG_CGROUP_MEM_RES_CTLR=y +CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y +CONFIG_CGROUP_SCHED=y +CONFIG_RT_GROUP_SCHED=y +CONFIG_BLK_CGROUP=y CONFIG_BLK_DEV_INITRD=y # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set -CONFIG_PERF_EVENTS=y +# CONFIG_COMPAT_BRK is not set CONFIG_SLAB=y +CONFIG_PROFILING=y +CONFIG_OPROFILE=y CONFIG_KPROBES=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y @@ -19,7 +30,9 @@ CONFIG_HIGH_RES_TIMERS=y CONFIG_PREEMPT=y CONFIG_MEMORY_HOTPLUG=y CONFIG_MEMORY_HOTREMOVE=y +CONFIG_KSM=y CONFIG_BINFMT_MISC=m +CONFIG_CMM=m CONFIG_HZ_100=y CONFIG_KEXEC=y CONFIG_PM=y @@ -105,6 +118,7 @@ CONFIG_DEBUG_LIST=y CONFIG_DEBUG_NOTIFIERS=y # CONFIG_RCU_CPU_STALL_DETECTOR is not set CONFIG_KPROBES_SANITY_TEST=y +CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y CONFIG_CPU_NOTIFIER_ERROR_INJECT=m CONFIG_LATENCYTOP=y CONFIG_SYSCTL_SYSCALL_CHECK=y From 9046e401e752dba784805a7818f99cc45a39cbff Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:22 +0100 Subject: [PATCH 03/13] [S390] mmap: consider stack address randomization Consider stack address randomization when calulating mmap_base for flexible mmap layout . Because of address randomization the stack address can be up to 8MB lower than STACK_TOP. When calculating mmap_base this isn't taken into account, which could lead to the case that the gap between the real stack top and mmap_base is lower than what ulimit specifies for the maximum stack size. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/elf.h | 2 ++ arch/s390/mm/mmap.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h index 354d42616c7e..9dbd3e7a3bc3 100644 --- a/arch/s390/include/asm/elf.h +++ b/arch/s390/include/asm/elf.h @@ -206,6 +206,8 @@ do { \ current->mm->context.noexec == 0; \ }) +#define STACK_RND_MASK 0x7ffUL + #define ARCH_DLINFO \ do { \ if (vdso_enabled) \ diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 869efbaed3ea..5578740ab9c9 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -30,6 +30,15 @@ #include #include +static unsigned long stack_maxrandom_size(void) +{ + if (!(current->flags & PF_RANDOMIZE)) + return 0; + if (current->personality & ADDR_NO_RANDOMIZE) + return 0; + return STACK_RND_MASK << PAGE_SHIFT; +} + /* * Top of mmap area (just below the process stack). * @@ -47,7 +56,7 @@ static inline unsigned long mmap_base(void) else if (gap > MAX_GAP) gap = MAX_GAP; - return STACK_TOP - (gap & PAGE_MASK); + return STACK_TOP - stack_maxrandom_size() - (gap & PAGE_MASK); } static inline int mmap_is_legacy(void) From 9e78a13bfb1640c058fde9dabfd386b942539018 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:23 +0100 Subject: [PATCH 04/13] [S390] reduce miminum gap between stack and mmap_base Reduce minimum gap between stack and mmap_base to 32MB. That way there is a bit more space for heap and mmap for tight 31 bit address spaces. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/mm/mmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 5578740ab9c9..89eff9e7b0b5 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -42,9 +42,9 @@ static unsigned long stack_maxrandom_size(void) /* * Top of mmap area (just below the process stack). * - * Leave an at least ~128 MB hole. + * Leave at least a ~32 MB hole. */ -#define MIN_GAP (128*1024*1024) +#define MIN_GAP (32*1024*1024) #define MAX_GAP (STACK_TOP/6*5) static inline unsigned long mmap_base(void) From e7828bbd5e8b7c8d6480d1eb744af821989ca432 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:24 +0100 Subject: [PATCH 05/13] [S390] vdso: dont map at mmap_base The vdso object is currently always mapped with mm->mmap_base used as requested address. In case of flexible mmap layout this means it gets mapped above mmap_base and therefore potentially stealing a bit of address space that is reserved for the stack. In case of flexible mmap layout the object should be mapped below mmap base. For legacy mmap layout above. To fix this just don't request any specific address and let the mmap code figure out an address that fits. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/vdso.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c index e3150dd2fe74..f438d74dedbd 100644 --- a/arch/s390/kernel/vdso.c +++ b/arch/s390/kernel/vdso.c @@ -203,7 +203,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) if (!uses_interp) return 0; - vdso_base = mm->mmap_base; #ifdef CONFIG_64BIT vdso_pagelist = vdso64_pagelist; vdso_pages = vdso64_pages; @@ -233,8 +232,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) * fail and end up putting it elsewhere. */ down_write(&mm->mmap_sem); - vdso_base = get_unmapped_area(NULL, vdso_base, - vdso_pages << PAGE_SHIFT, 0, 0); + vdso_base = get_unmapped_area(NULL, 0, vdso_pages << PAGE_SHIFT, 0, 0); if (IS_ERR_VALUE(vdso_base)) { rc = vdso_base; goto out_up; From 7e0d48574ec371e26fa31e23d1d314f04e31eb3e Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:25 +0100 Subject: [PATCH 06/13] [S390] Enable flexible mmap layout for 64 bit processes Historically 64 bit processes use the legacy address layout. However there is no reason why 64 bit processes shouldn't benefit from the flexible mmap layout advantages. Therefore just enable it. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/mm/mmap.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 89eff9e7b0b5..ab7e08a01b6c 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -61,16 +61,11 @@ static inline unsigned long mmap_base(void) static inline int mmap_is_legacy(void) { -#ifdef CONFIG_64BIT - /* - * Force standard allocation for 64 bit programs. - */ - if (!is_compat_task()) + if (current->personality & ADDR_COMPAT_LAYOUT) return 1; -#endif - return sysctl_legacy_va_layout || - (current->personality & ADDR_COMPAT_LAYOUT) || - rlimit(RLIMIT_STACK) == RLIM_INFINITY; + if (rlimit(RLIMIT_STACK) == RLIM_INFINITY) + return 1; + return sysctl_legacy_va_layout; } #ifndef CONFIG_64BIT From 1060f62ea47e609b0c1672e8d1ac216e57f11a8e Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:26 +0100 Subject: [PATCH 07/13] [S390] Rearrange mmap.c Shuffle code around so it looks more like x86 and powerpc. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/mm/mmap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index ab7e08a01b6c..74d663f367e2 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -47,6 +47,15 @@ static unsigned long stack_maxrandom_size(void) #define MIN_GAP (32*1024*1024) #define MAX_GAP (STACK_TOP/6*5) +static inline int mmap_is_legacy(void) +{ + if (current->personality & ADDR_COMPAT_LAYOUT) + return 1; + if (rlimit(RLIMIT_STACK) == RLIM_INFINITY) + return 1; + return sysctl_legacy_va_layout; +} + static inline unsigned long mmap_base(void) { unsigned long gap = rlimit(RLIMIT_STACK); @@ -59,15 +68,6 @@ static inline unsigned long mmap_base(void) return STACK_TOP - stack_maxrandom_size() - (gap & PAGE_MASK); } -static inline int mmap_is_legacy(void) -{ - if (current->personality & ADDR_COMPAT_LAYOUT) - return 1; - if (rlimit(RLIMIT_STACK) == RLIM_INFINITY) - return 1; - return sysctl_legacy_va_layout; -} - #ifndef CONFIG_64BIT /* From df1ca53cba34b1d40a4ed47907d71397e4ee72c2 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:27 +0100 Subject: [PATCH 08/13] [S390] Randomize mmap start address Randomize mmap start address with 8MB. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/mm/mmap.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 74d663f367e2..c9a9f7f18188 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,14 @@ static inline int mmap_is_legacy(void) return sysctl_legacy_va_layout; } +static unsigned long mmap_rnd(void) +{ + if (!(current->flags & PF_RANDOMIZE)) + return 0; + /* 8MB randomization for mmap_base */ + return (get_random_int() & 0x7ffUL) << PAGE_SHIFT; +} + static inline unsigned long mmap_base(void) { unsigned long gap = rlimit(RLIMIT_STACK); @@ -64,8 +73,8 @@ static inline unsigned long mmap_base(void) gap = MIN_GAP; else if (gap > MAX_GAP) gap = MAX_GAP; - - return STACK_TOP - stack_maxrandom_size() - (gap & PAGE_MASK); + gap &= PAGE_MASK; + return STACK_TOP - stack_maxrandom_size() - mmap_rnd() - gap; } #ifndef CONFIG_64BIT From 9887a1fcddef1386d3387edf6497d08670460edb Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:28 +0100 Subject: [PATCH 09/13] [S390] Randomize lower bits of stack address Randomize the lower bits of the stack address like x86 and powerpc. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/system.h | 2 +- arch/s390/kernel/process.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/s390/include/asm/system.h b/arch/s390/include/asm/system.h index 6710b0eac165..8f8d759f6a7b 100644 --- a/arch/s390/include/asm/system.h +++ b/arch/s390/include/asm/system.h @@ -449,7 +449,7 @@ extern void (*_machine_restart)(char *command); extern void (*_machine_halt)(void); extern void (*_machine_power_off)(void); -#define arch_align_stack(x) (x) +extern unsigned long arch_align_stack(unsigned long sp); static inline int tprot(unsigned long addr) { diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 6ba42222b542..38ff69e562c8 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c @@ -30,9 +30,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -332,3 +334,10 @@ unsigned long get_wchan(struct task_struct *p) } return 0; } + +unsigned long arch_align_stack(unsigned long sp) +{ + if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space) + sp -= get_random_int() & ~PAGE_MASK; + return sp & ~0xf; +} From a05c90f1948baacedd0c3e7e3250225be4cae727 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:29 +0100 Subject: [PATCH 10/13] [S390] Add is_32bit_task() helper function Helper function which tells us if a task is running in ESA mode. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/compat.h | 2 +- arch/s390/include/asm/thread_info.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h index a875c2f542e1..da359ca6fe55 100644 --- a/arch/s390/include/asm/compat.h +++ b/arch/s390/include/asm/compat.h @@ -169,7 +169,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr) static inline int is_compat_task(void) { - return test_thread_flag(TIF_31BIT); + return is_32bit_task(); } #else diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h index ebc77091466f..ad1382f7932e 100644 --- a/arch/s390/include/asm/thread_info.h +++ b/arch/s390/include/asm/thread_info.h @@ -118,6 +118,12 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_SINGLE_STEP (1< Date: Wed, 12 Jan 2011 09:55:30 +0100 Subject: [PATCH 11/13] [S390] Randomise the brk region Randomize heap address like other architectures do already. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/elf.h | 3 +++ arch/s390/kernel/process.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h index 9dbd3e7a3bc3..457fb7c16236 100644 --- a/arch/s390/include/asm/elf.h +++ b/arch/s390/include/asm/elf.h @@ -220,4 +220,7 @@ struct linux_binprm; #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 int arch_setup_additional_pages(struct linux_binprm *, int); +extern unsigned long arch_randomize_brk(struct mm_struct *mm); +#define arch_randomize_brk arch_randomize_brk + #endif diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 38ff69e562c8..26d48fe72999 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c @@ -341,3 +341,21 @@ unsigned long arch_align_stack(unsigned long sp) sp -= get_random_int() & ~PAGE_MASK; return sp & ~0xf; } + +static inline unsigned long brk_rnd(void) +{ + /* 8MB for 32bit, 1GB for 64bit */ + if (is_32bit_task()) + return (get_random_int() & 0x7ffUL) << PAGE_SHIFT; + else + return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT; +} + +unsigned long arch_randomize_brk(struct mm_struct *mm) +{ + unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd()); + + if (ret < mm->brk) + return mm->brk; + return ret; +} From d2c9dfccbc3a449b9677772e7496e2656049d9f3 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:31 +0100 Subject: [PATCH 12/13] [S390] Randomize PIEs Randomize ELF_ET_DYN_BASE, which is used when loading position independent executables. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/elf.h | 4 +++- arch/s390/kernel/process.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h index 457fb7c16236..10c029cfcc7d 100644 --- a/arch/s390/include/asm/elf.h +++ b/arch/s390/include/asm/elf.h @@ -161,7 +161,9 @@ extern unsigned int vdso_enabled; use of this is to invoke "./ld.so someprog" to test out a new version of the loader. We need to make sure that it is out of the way of the program that it will "exec", and that there is sufficient room for the brk. */ -#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2) + +extern unsigned long randomize_et_dyn(unsigned long base); +#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2)) /* This yields a mask that user programs can use to figure out what instruction set this CPU supports. */ diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 26d48fe72999..a895e69379f7 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c @@ -359,3 +359,14 @@ unsigned long arch_randomize_brk(struct mm_struct *mm) return mm->brk; return ret; } + +unsigned long randomize_et_dyn(unsigned long base) +{ + unsigned long ret = PAGE_ALIGN(base + brk_rnd()); + + if (!(current->flags & PF_RANDOMIZE)) + return base; + if (ret < base) + return base; + return ret; +} From 51120c2cc70fc241721b8016f4eff575e7d6aa30 Mon Sep 17 00:00:00 2001 From: Holger Dengler Date: Wed, 12 Jan 2011 09:55:32 +0100 Subject: [PATCH 13/13] [S390] MAINTAINERS: Update zcrypt driver entry Holger will take over the zcrypt driver maintainer work. Update the MAINTAINERS entry accordingly. Signed-off-by: Holger Dengler Signed-off-by: Felix Beck --- MAINTAINERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 42f991e5a85d..6ce9191d658d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5243,8 +5243,7 @@ S: Supported F: drivers/s390/net/ S390 ZCRYPT DRIVER -M: Felix Beck -M: Ralph Wuerthner +M: Holger Dengler M: linux390@de.ibm.com L: linux-s390@vger.kernel.org W: http://www.ibm.com/developerworks/linux/linux390/