Commit c5599b90 authored by Heiko Carstens's avatar Heiko Carstens Committed by Greg Kroah-Hartman

s390/ptrace: fix storage key handling

[ Upstream commit fd78c594 ]

The key member of the runtime instrumentation control block contains
only the access key, not the complete storage key. Therefore the value
must be shifted by four bits. Since existing user space does not
necessarily query and set the access key correctly, just ignore the
user space provided key and use the correct one.
Note: this is only relevant for debugging purposes in case somebody
compiles a kernel with a default storage access key set to a value not
equal to zero.

Fixes: 262832bc ("s390/ptrace: add runtime instrumention register get/set")
Reported-by: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5a5120b1
...@@ -1286,7 +1286,6 @@ static bool is_ri_cb_valid(struct runtime_instr_cb *cb) ...@@ -1286,7 +1286,6 @@ static bool is_ri_cb_valid(struct runtime_instr_cb *cb)
cb->pc == 1 && cb->pc == 1 &&
cb->qc == 0 && cb->qc == 0 &&
cb->reserved2 == 0 && cb->reserved2 == 0 &&
cb->key == PAGE_DEFAULT_KEY &&
cb->reserved3 == 0 && cb->reserved3 == 0 &&
cb->reserved4 == 0 && cb->reserved4 == 0 &&
cb->reserved5 == 0 && cb->reserved5 == 0 &&
...@@ -1350,7 +1349,11 @@ static int s390_runtime_instr_set(struct task_struct *target, ...@@ -1350,7 +1349,11 @@ static int s390_runtime_instr_set(struct task_struct *target,
kfree(data); kfree(data);
return -EINVAL; return -EINVAL;
} }
/*
* Override access key in any case, since user space should
* not be able to set it, nor should it care about it.
*/
ri_cb.key = PAGE_DEFAULT_KEY >> 4;
preempt_disable(); preempt_disable();
if (!target->thread.ri_cb) if (!target->thread.ri_cb)
target->thread.ri_cb = data; target->thread.ri_cb = data;
......
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