public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
To: git-commits@fedoraproject.org
Subject: [rpms/ocserv] epel10: fix pam-guard-page test
Date: Wed, 10 Jun 2026 18:52:09 GMT	[thread overview]
Message-ID: <178111752938.1.5261566861556347119.rpms-ocserv-15ec412a1a38@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/ocserv
Branch : epel10
Commit : 15ec412a1a384c9ff5c16c67f08299c8a73039ea
Author : Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Date   : 2026-06-10T20:51:50+02:00
Stats  : +102/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/ocserv/c/15ec412a1a384c9ff5c16c67f08299c8a73039ea?branch=epel10

Log:
fix pam-guard-page test

---
diff --git a/ocserv.spec b/ocserv.spec
index dc338e6..b6d3b3f 100644
--- a/ocserv.spec
+++ b/ocserv.spec
@@ -23,6 +23,8 @@ Source8:	ocserv-genkey
 Source9:	ocserv-script
 Source10:	gpgkey-56EE7FA9E8173B19FE86268D763712747F343FA7.gpg
 
+Patch0:		pam-guard-page.patch
+
 BuildRequires: meson
 BuildRequires: libxcrypt-devel
 BuildRequires:	gcc

diff --git a/pam-guard-page.patch b/pam-guard-page.patch
new file mode 100644
index 0000000..d7427f3
--- /dev/null
+++ b/pam-guard-page.patch
@@ -0,0 +1,100 @@
+diff --git a/tests/pam-guard-page.c b/tests/pam-guard-page.c
+index 76d1cdf3..5aab14da 100644
+--- a/tests/pam-guard-page.c
++++ b/tests/pam-guard-page.c
+@@ -59,6 +59,10 @@ static char altstack_buf[65536];
+ static void *guard_base;
+ static size_t guard_size;
+ 
++/* Incremented by recurse(); reported by the SIGALRM handler to show whether
++ * the stack grew (low count) or TCO turned the recursion into a flat loop. */
++static volatile sig_atomic_t recurse_count;
++
+ static void sigsegv_handler(int sig, siginfo_t *si, void *ctx)
+ {
+ 	(void)sig;
+@@ -67,21 +71,37 @@ static void sigsegv_handler(int sig, siginfo_t *si, void *ctx)
+ 	if ((char *)si->si_addr >= (char *)guard_base &&
+ 	    (char *)si->si_addr < (char *)guard_base + guard_size)
+ 		_exit(0);
+-	/* Fault elsewhere — not the guard page; report failure. */
++	fprintf(stderr, "FAIL: SIGSEGV outside guard page, fault_addr=%p\n",
++		si->si_addr);
+ 	_exit(1);
+ }
+ 
++/* SIGALRM fires if the stack never overflows within the deadline. */
++static void sigalrm_handler(int sig)
++{
++	(void)sig;
++	fprintf(stderr,
++		"FAIL: no stack overflow after %d iterations"
++		" — tail-call optimization suppressed stack growth\n",
++		recurse_count);
++	_exit(3);
++}
++
+ static void recurse(int depth);
+ /* volatile pointer breaks static infinite-recursion analysis */
+ static void (*volatile recurse_ptr)(int) = recurse;
+ 
+-/* Each frame consumes ~512 bytes; ~128 frames exhaust a 64 KB stack. */
++/* Each frame consumes ~512 bytes; ~128 frames exhaust a 64 KB stack.
++ * frame[0] is read AFTER the recursive call so the frame stays live across
++ * the call — this prevents the compiler from tail-calling recurse_ptr even
++ * with optimizations. */
+ static void recurse(int depth)
+ {
+ 	volatile char frame[512];
+ 	frame[0] = (char)depth;
+-	(void)frame[0]; /* read back to prevent the frame being optimized away */
++	recurse_count++;
+ 	recurse_ptr(depth + 1);
++	(void)frame[0];
+ }
+ 
+ static void overflow_coroutine(void *data)
+@@ -138,6 +158,13 @@ int main(void)
+ 			_exit(1);
+ 		}
+ 
++		/* Arm a 10-second deadline so that if the stack never overflows
++		 * (e.g. the compiler tail-called recurse_ptr and no frame
++		 * accumulates) the child exits with a diagnostic instead of
++		 * hanging until the meson timeout fires. */
++		signal(SIGALRM, sigalrm_handler);
++		alarm(10);
++
+ 		coroutine_t cr = co_create(overflow_coroutine, NULL, stack,
+ 					   TEST_STACK_SIZE);
+ 		if (cr == NULL) {
+@@ -163,16 +190,23 @@ int main(void)
+ 		return 0;
+ 	}
+ 
+-	if (WIFEXITED(status))
+-		fprintf(stderr,
+-			"FAIL: child exited with status %d "
+-			"(fault outside guard page or no fault)\n",
+-			WEXITSTATUS(status));
+-	else
++	if (WIFEXITED(status)) {
++		int code = WEXITSTATUS(status);
++		if (code == 3)
++			fprintf(stderr,
++				"FAIL: child SIGALRM fired — "
++				"stack never overflowed (tail-call optimization?)\n");
++		else
++			fprintf(stderr,
++				"FAIL: child exited with status %d "
++				"(fault outside guard page or setup error)\n",
++				code);
++	} else {
+ 		fprintf(stderr,
+ 			"FAIL: child killed by signal %d "
+ 			"(SIGSEGV handler did not run?)\n",
+ 			WTERMSIG(status));
++	}
+ 	return 1;
+ }
+ 

                 reply	other threads:[~2026-06-10 18:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178111752938.1.5261566861556347119.rpms-ocserv-15ec412a1a38@fedoraproject.org \
    --to=n.mavrogiannopoulos@gmail.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox