Skip to content

Commit dcede75

Browse files
Martin Schwidefskygregkh
authored andcommitted
s390/ptrace: fix PSW mask check
commit dab6cf5 upstream. The PSW mask check of the PTRACE_POKEUSR_AREA command is incorrect. The PSW_MASK_USER define contains the PSW_MASK_ASC bits, the ptrace interface accepts all combinations for the address-space-control bits. To protect the kernel space the PSW mask check in ptrace needs to reject the address-space-control bit combination for home space. Fixes CVE-2014-3534 Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a8f3f50 commit dcede75

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎arch/s390/kernel/ptrace.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,14 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)
334334
unsigned long mask = PSW_MASK_USER;
335335

336336
mask |= is_ri_task(child) ? PSW_MASK_RI : 0;
337-
if ((data & ~mask) != PSW_USER_BITS)
337+
if ((data ^ PSW_USER_BITS) & ~mask)
338+
/* Invalid psw mask. */
339+
return -EINVAL;
340+
if ((data & PSW_MASK_ASC) == PSW_ASC_HOME)
341+
/* Invalid address-space-control bits */
338342
return -EINVAL;
339343
if ((data & PSW_MASK_EA) && !(data & PSW_MASK_BA))
344+
/* Invalid addressing mode bits */
340345
return -EINVAL;
341346
}
342347
*(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data;
@@ -672,9 +677,12 @@ static int __poke_user_compat(struct task_struct *child,
672677

673678
mask |= is_ri_task(child) ? PSW32_MASK_RI : 0;
674679
/* Build a 64 bit psw mask from 31 bit mask. */
675-
if ((tmp & ~mask) != PSW32_USER_BITS)
680+
if ((tmp ^ PSW32_USER_BITS) & ~mask)
676681
/* Invalid psw mask. */
677682
return -EINVAL;
683+
if ((data & PSW32_MASK_ASC) == PSW32_ASC_HOME)
684+
/* Invalid address-space-control bits */
685+
return -EINVAL;
678686
regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |
679687
(regs->psw.mask & PSW_MASK_BA) |
680688
(__u64)(tmp & mask) << 32;

0 commit comments

Comments
 (0)