Skip to content

Commit

Permalink
s390/ptrace: fix PSW mask check
Browse files Browse the repository at this point in the history
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>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Martin Schwidefsky authored and Greg Kroah-Hartman committed Jul 31, 2014
1 parent e5c662d commit 883ea13
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions arch/s390/kernel/ptrace.c
Original file line number Diff line number Diff line change
@@ -292,7 +292,9 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)
* psw and gprs are stored on the stack
*/
if (addr == (addr_t) &dummy->regs.psw.mask &&
((data & ~PSW_MASK_USER) != psw_user_bits ||
(((data^psw_user_bits) & ~PSW_MASK_USER) ||
(((data^psw_user_bits) & PSW_MASK_ASC) &&
((data|psw_user_bits) & PSW_MASK_ASC) == PSW_MASK_ASC) ||
((data & PSW_MASK_EA) && !(data & PSW_MASK_BA))))
/* Invalid psw mask. */
return -EINVAL;
@@ -595,7 +597,10 @@ static int __poke_user_compat(struct task_struct *child,
*/
if (addr == (addr_t) &dummy32->regs.psw.mask) {
/* Build a 64 bit psw mask from 31 bit mask. */
if ((tmp & ~PSW32_MASK_USER) != psw32_user_bits)
if (((tmp^psw32_user_bits) & ~PSW32_MASK_USER) ||
(((tmp^psw32_user_bits) & PSW32_MASK_ASC) &&
((tmp|psw32_user_bits) & PSW32_MASK_ASC)
== PSW32_MASK_ASC))
/* Invalid psw mask. */
return -EINVAL;
regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |

0 comments on commit 883ea13

Please sign in to comment.