Skip to content

Commit fd78c59

Browse files
committed
s390/ptrace: fix storage key handling
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 <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent 9eaba29 commit fd78c59

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/s390/kernel/ptrace.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,6 @@ static bool is_ri_cb_valid(struct runtime_instr_cb *cb)
12681268
cb->pc == 1 &&
12691269
cb->qc == 0 &&
12701270
cb->reserved2 == 0 &&
1271-
cb->key == PAGE_DEFAULT_KEY &&
12721271
cb->reserved3 == 0 &&
12731272
cb->reserved4 == 0 &&
12741273
cb->reserved5 == 0 &&
@@ -1330,7 +1329,11 @@ static int s390_runtime_instr_set(struct task_struct *target,
13301329
kfree(data);
13311330
return -EINVAL;
13321331
}
1333-
1332+
/*
1333+
* Override access key in any case, since user space should
1334+
* not be able to set it, nor should it care about it.
1335+
*/
1336+
ri_cb.key = PAGE_DEFAULT_KEY >> 4;
13341337
preempt_disable();
13351338
if (!target->thread.ri_cb)
13361339
target->thread.ri_cb = data;

0 commit comments

Comments
 (0)