Skip to content

Commit c5599b9

Browse files
hcahcagregkh
authored andcommitted
s390/ptrace: fix storage key handling
[ Upstream commit fd78c59 ] 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: 262832b ("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>
1 parent 5a5120b commit c5599b9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

arch/s390/kernel/ptrace.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,6 @@ static bool is_ri_cb_valid(struct runtime_instr_cb *cb)
12861286
cb->pc == 1 &&
12871287
cb->qc == 0 &&
12881288
cb->reserved2 == 0 &&
1289-
cb->key == PAGE_DEFAULT_KEY &&
12901289
cb->reserved3 == 0 &&
12911290
cb->reserved4 == 0 &&
12921291
cb->reserved5 == 0 &&
@@ -1350,7 +1349,11 @@ static int s390_runtime_instr_set(struct task_struct *target,
13501349
kfree(data);
13511350
return -EINVAL;
13521351
}
1353-
1352+
/*
1353+
* Override access key in any case, since user space should
1354+
* not be able to set it, nor should it care about it.
1355+
*/
1356+
ri_cb.key = PAGE_DEFAULT_KEY >> 4;
13541357
preempt_disable();
13551358
if (!target->thread.ri_cb)
13561359
target->thread.ri_cb = data;

0 commit comments

Comments
 (0)