OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH vz10] selftests: syscall_user_dispatch: keep the frame pointer in sud_benchmark
@ 2026-09-08 21:32 Eva Kurchatova
  2026-09-23 18:59 ` Konstantin Khorenko
  2026-09-23 19:23 ` Konstantin Khorenko
  0 siblings, 2 replies; 3+ messages in thread
From: Eva Kurchatova @ 2026-09-08 21:32 UTC (permalink / raw)
  To: khorenko; +Cc: devel

The SIGSYS handler returns by hand: it loads __NR_rt_sigreturn, runs
leaveq to drop its frame, adjusts the stack and issues the syscall. leaveq
restores the stack from the frame pointer, so the sequence only works in a
function that has one.

gcc omits the frame pointer from -O1 up, so the handler restores a stack
that is not the signal frame and rt_sigreturn resumes at a bogus address:

  Caught sys_ff00
  Segmentation fault

Upstream never sees it, as the Makefile passes no -O and the default is
-O0, but the tests here are built with the distribution optimisation
flags. Measured: -O0 passes, -O1 and -O2 fault, and either of them with
-fno-omit-frame-pointer passes.

Ask for the frame pointer, which is what the assembly needs. sud_test is
unaffected either way.

https://virtuozzo.atlassian.net/browse/VSTOR-144593
Feature: fix selftests

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/syscall_user_dispatch/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/syscall_user_dispatch/Makefile b/tools/testing/selftests/syscall_user_dispatch/Makefile
index 03c120270953..249d9ed30c5c 100644
--- a/tools/testing/selftests/syscall_user_dispatch/Makefile
+++ b/tools/testing/selftests/syscall_user_dispatch/Makefile
@@ -3,7 +3,7 @@ top_srcdir = ../../../..
 INSTALL_HDR_PATH = $(top_srcdir)/usr
 LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
 
-CFLAGS += -Wall -I$(LINUX_HDR_PATH)
+CFLAGS += -Wall -fno-omit-frame-pointer -I$(LINUX_HDR_PATH)
 
 TEST_GEN_PROGS := sud_test sud_benchmark
 include ../lib.mk
-- 
2.55.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Devel] [PATCH vz10] selftests: syscall_user_dispatch: keep the frame pointer in sud_benchmark
  2026-09-08 21:32 [Devel] [PATCH vz10] selftests: syscall_user_dispatch: keep the frame pointer in sud_benchmark Eva Kurchatova
@ 2026-09-23 18:59 ` Konstantin Khorenko
  2026-09-23 19:23 ` Konstantin Khorenko
  1 sibling, 0 replies; 3+ messages in thread
From: Konstantin Khorenko @ 2026-09-23 18:59 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

On Wed, 09 Sep 2026 00:32:59 +0300, Eva Kurchatova <eva.kurchatova@virtuozzo.com> wrote:
> The SIGSYS handler returns by hand: it loads __NR_rt_sigreturn, runs
> leaveq to drop its frame, adjusts the stack and issues the syscall. leaveq
> restores the stack from the frame pointer, so the sequence only works in a
> function that has one.
> 
> gcc omits the frame pointer from -O1 up, so the handler restores a stack
> that is not the signal frame and rt_sigreturn resumes at a bogus address:
> 
> [...]

Reviewed-by: Konstantin Khorenko <khorenko@virtuozzo.com>

-- 
Konstantin Khorenko <khorenko@virtuozzo.com>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Devel] [PATCH vz10] selftests: syscall_user_dispatch: keep the frame pointer in sud_benchmark
  2026-09-08 21:32 [Devel] [PATCH vz10] selftests: syscall_user_dispatch: keep the frame pointer in sud_benchmark Eva Kurchatova
  2026-09-23 18:59 ` Konstantin Khorenko
@ 2026-09-23 19:23 ` Konstantin Khorenko
  1 sibling, 0 replies; 3+ messages in thread
From: Konstantin Khorenko @ 2026-09-23 19:23 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

On Wed, 09 Sep 2026 00:32:59 +0300, Eva Kurchatova wrote:
> selftests: syscall_user_dispatch: keep the frame pointer in sud_benchmark

Applied to branch-rh10-6.12.0-211.52.1.22.x.vz10-ovz, will be released in rh10-6.12.0-211.52.1.22.3.vz10, thanks!

[1/1] selftests: syscall_user_dispatch: keep the frame pointer in sud_benchmark
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/f4f9fbd41d5a

-- 
Konstantin Khorenko <khorenko@virtuozzo.com>

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-23 19:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 21:32 [Devel] [PATCH vz10] selftests: syscall_user_dispatch: keep the frame pointer in sud_benchmark Eva Kurchatova
2026-09-23 18:59 ` Konstantin Khorenko
2026-09-23 19:23 ` Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox