summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2020-08-12 18:56:28 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-08-26 10:31:03 +0200
commitc5599b901df07d2a91e8b13f35f0393a25b2b832 (patch)
tree637c842b6ec72e8a4f588a200e8b5f8394c21c9f
parent5a5120b162798fdf07147dff03b23b69f147d311 (diff)
downloadlinux-stable-c5599b901df07d2a91e8b13f35f0393a25b2b832.tar.gz
linux-stable-c5599b901df07d2a91e8b13f35f0393a25b2b832.tar.bz2
linux-stable-c5599b901df07d2a91e8b13f35f0393a25b2b832.zip
s390/ptrace: fix storage key handling
[ Upstream commit fd78c59446b8d050ecf3e0897c5a486c7de7c595 ] 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: 262832bc5acd ("s390/ptrace: add runtime instrumention register get/set") Reported-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--arch/s390/kernel/ptrace.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 65fefbf61e1c..3ffa2847c110 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -1286,7 +1286,6 @@ static bool is_ri_cb_valid(struct runtime_instr_cb *cb)
cb->pc == 1 &&
cb->qc == 0 &&
cb->reserved2 == 0 &&
- cb->key == PAGE_DEFAULT_KEY &&
cb->reserved3 == 0 &&
cb->reserved4 == 0 &&
cb->reserved5 == 0 &&
@@ -1350,7 +1349,11 @@ static int s390_runtime_instr_set(struct task_struct *target,
kfree(data);
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();
if (!target->thread.ri_cb)
target->thread.ri_cb = data;