Skip to contentSkip to conversation

s390/uprobes: Fix off-by-one bug in emulated PER handling

PATCH In review Heiko Carstens 3 participants 3 messages Oct 9 – Oct 12

Subsystems (2)
lore
Share & tools
lore

Heiko Carstens

author maintainer
#0 lore raw

PATCH 1/1 s390/uprobes: Fix off-by-one bug in emulated PER handling

The uprobes code emulates some instructions, and with that also PER storage-alteration handling, in case a debugger is attached.

The PER storage-alteration handling contains an off-by-one bug, which may lead to PER traps which should not happen. Adjust the comparison in sim_stor_event() to fix that.

Fixes 8d1a2427d8fc ("s390/uprobes: fix user space PER events")
---
 arch/s390/kernel/uprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/uprobes.c +1 -1
index c624f3361e43..b2b8a377ced6 100644
@@ -241,7 +241,7 @@ static void sim_stor_event(struct pt_regs *regs, void *addr, int len)
 		return;
 	if (!(current->thread.per_user.control & PER_EVENT_STORE))
 		return;
-	if ((void *)current->thread.per_user.start > (addr + len))
+	if ((void *)current->thread.per_user.start > (addr + len - 1))
 		return;
 	if ((void *)current->thread.per_user.end < addr)
 		return;
Signature · 1 line
2.53.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines

The uprobes code emulates some instructions, and with that also PER storage-alteration handling, in case a debugger is attached.

The PER storage-alteration handling contains an off-by-one bug, which may lead to PER traps which should not happen. Adjust the comparison in sim_stor_event() to fix that.

Fixes 8d1a2427d8fc ("s390/uprobes: fix user space PER events")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Heiko Carstens
Quoted 18 lines · Heiko Carstens

The uprobes code emulates some instructions, and with that also PER storage-alteration handling, in case a debugger is attached.

The PER storage-alteration handling contains an off-by-one bug, which may lead to PER traps which should not happen. Adjust the comparison in sim_stor_event() to fix that.

Fixes 8d1a2427d8fc ("s390/uprobes: fix user space PER events")
---
 arch/s390/kernel/uprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/uprobes.c +0 -0
index c624f3361e43..b2b8a377ced6 100644

arch/s390/kernel/uprobes.c static void sim_stor_event(struct pt_regs *regs, void *addr, int len) · line 247

Quoted 8 lines
arch/s390/kernel/uprobes.c +1 -1
@@ -241,7 +241,7 @@ static void sim_stor_event(struct pt_regs *regs, void *addr, int len)
 		return;
 	if (!(current->thread.per_user.control & PER_EVENT_STORE))
 		return;
-	if ((void *)current->thread.per_user.start > (addr + len))
+	if ((void *)current->thread.per_user.start > (addr + len - 1))
 		return;
 	if ((void *)current->thread.per_user.end < addr)
 		return;