Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[S390] kprobes: Align probe address.

Running a probe on s390 with a probe address that is not 4 byte aligned
results in a Kernel BUG. The problem is that the stura instruction used
by swap_instruction requires the destination address to be 4 byte aligned.
As stura only writes 4 bytes, aligning to the next 4 byte aligned address
results in the breakpoint instruction being stored past the probe address.
The fix is to align the address backward (to the previous 4 byte aligned
address) and writing the two byte breakpoint instruction in the appropriate
bytes.

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: David Wilder <dwilder@us.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>

authored by

David Wilder and committed by
Heiko Carstens
b70842df afbc1e99

+1 -1
+1 -1
arch/s390/kernel/kprobes.c
··· 167 167 * shall not cross any page boundaries (vmalloc area!) when writing 168 168 * the new instruction. 169 169 */ 170 - addr = (u32 *)ALIGN((unsigned long)args->ptr, 4); 170 + addr = (u32 *)((unsigned long)args->ptr & -4UL); 171 171 if ((unsigned long)args->ptr & 2) 172 172 instr = ((*addr) & 0xffff0000) | args->new; 173 173 else