Commit 4b470f12 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'parisc-4.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux

Pull parisc fixes from Helge Deller:
 "One important patch which fixes crashes due to stack randomization on
  architectures where the stack grows upwards (currently parisc and
  metag only).

  This bug went unnoticed on parisc since kernel 3.14 where the flexible
  mmap memory layout support was added by commit 9dabf60d.  The
  changes in fs/exec.c are inside an #ifdef CONFIG_STACK_GROWSUP section
  and will not affect other platforms.

  The other two patches rename args of the kthread_arg() function and
  fixes a printk output"

* 'parisc-4.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
  parisc,metag: Fix crashes due to stack randomization on stack-grows-upwards architectures
  parisc: copy_thread(): rename 'arg' argument to 'kthread_arg'
  parisc: %pf is only for function pointers
parents be5e32fc d045c77c
...@@ -348,6 +348,10 @@ struct pt_regs; /* forward declaration... */ ...@@ -348,6 +348,10 @@ struct pt_regs; /* forward declaration... */
#define ELF_HWCAP 0 #define ELF_HWCAP 0
#define STACK_RND_MASK (is_32bit_task() ? \
0x7ff >> (PAGE_SHIFT - 12) : \
0x3ffff >> (PAGE_SHIFT - 12))
struct mm_struct; struct mm_struct;
extern unsigned long arch_randomize_brk(struct mm_struct *); extern unsigned long arch_randomize_brk(struct mm_struct *);
#define arch_randomize_brk arch_randomize_brk #define arch_randomize_brk arch_randomize_brk
......
...@@ -181,9 +181,12 @@ int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r) ...@@ -181,9 +181,12 @@ int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r)
return 1; return 1;
} }
/*
* Copy architecture-specific thread state
*/
int int
copy_thread(unsigned long clone_flags, unsigned long usp, copy_thread(unsigned long clone_flags, unsigned long usp,
unsigned long arg, struct task_struct *p) unsigned long kthread_arg, struct task_struct *p)
{ {
struct pt_regs *cregs = &(p->thread.regs); struct pt_regs *cregs = &(p->thread.regs);
void *stack = task_stack_page(p); void *stack = task_stack_page(p);
...@@ -195,11 +198,10 @@ copy_thread(unsigned long clone_flags, unsigned long usp, ...@@ -195,11 +198,10 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
extern void * const child_return; extern void * const child_return;
if (unlikely(p->flags & PF_KTHREAD)) { if (unlikely(p->flags & PF_KTHREAD)) {
/* kernel thread */
memset(cregs, 0, sizeof(struct pt_regs)); memset(cregs, 0, sizeof(struct pt_regs));
if (!usp) /* idle thread */ if (!usp) /* idle thread */
return 0; return 0;
/* kernel thread */
/* Must exit via ret_from_kernel_thread in order /* Must exit via ret_from_kernel_thread in order
* to call schedule_tail() * to call schedule_tail()
*/ */
...@@ -215,7 +217,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp, ...@@ -215,7 +217,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
#else #else
cregs->gr[26] = usp; cregs->gr[26] = usp;
#endif #endif
cregs->gr[25] = arg; cregs->gr[25] = kthread_arg;
} else { } else {
/* user thread */ /* user thread */
/* usp must be word aligned. This also prevents users from /* usp must be word aligned. This also prevents users from
......
...@@ -77,6 +77,9 @@ static unsigned long mmap_upper_limit(void) ...@@ -77,6 +77,9 @@ static unsigned long mmap_upper_limit(void)
if (stack_base > STACK_SIZE_MAX) if (stack_base > STACK_SIZE_MAX)
stack_base = STACK_SIZE_MAX; stack_base = STACK_SIZE_MAX;
/* Add space for stack randomization. */
stack_base += (STACK_RND_MASK << PAGE_SHIFT);
return PAGE_ALIGN(STACK_TOP - stack_base); return PAGE_ALIGN(STACK_TOP - stack_base);
} }
......
...@@ -348,7 +348,7 @@ int superio_fixup_irq(struct pci_dev *pcidev) ...@@ -348,7 +348,7 @@ int superio_fixup_irq(struct pci_dev *pcidev)
BUG(); BUG();
return -1; return -1;
} }
printk("superio_fixup_irq(%s) ven 0x%x dev 0x%x from %pf\n", printk(KERN_DEBUG "superio_fixup_irq(%s) ven 0x%x dev 0x%x from %ps\n",
pci_name(pcidev), pci_name(pcidev),
pcidev->vendor, pcidev->device, pcidev->vendor, pcidev->device,
__builtin_return_address(0)); __builtin_return_address(0));
......
...@@ -659,6 +659,9 @@ int setup_arg_pages(struct linux_binprm *bprm, ...@@ -659,6 +659,9 @@ int setup_arg_pages(struct linux_binprm *bprm,
if (stack_base > STACK_SIZE_MAX) if (stack_base > STACK_SIZE_MAX)
stack_base = STACK_SIZE_MAX; stack_base = STACK_SIZE_MAX;
/* Add space for stack randomization. */
stack_base += (STACK_RND_MASK << PAGE_SHIFT);
/* Make sure we didn't let the argument array grow too large. */ /* Make sure we didn't let the argument array grow too large. */
if (vma->vm_end - vma->vm_start > stack_base) if (vma->vm_end - vma->vm_start > stack_base)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment