* [LTP] [PATCH] cgroup_core02: Allocate child stack using mmap()
@ 2025-01-17 14:48 Martin Doucha
2025-01-17 15:03 ` Petr Vorel
2025-01-17 16:05 ` Cyril Hrubis
0 siblings, 2 replies; 3+ messages in thread
From: Martin Doucha @ 2025-01-17 14:48 UTC (permalink / raw)
To: ltp
Some architectures like arm64 have strict requirements for stack alignment.
Statically allocated buffer may result in one of the test processes
getting killed by SIGBUS. Allocate child stack using mmap() to ensure
the requirements are met.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
testcases/kernel/controllers/cgroup/cgroup_core02.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/controllers/cgroup/cgroup_core02.c b/testcases/kernel/controllers/cgroup/cgroup_core02.c
index 733e88ee7..e0b96ecf4 100644
--- a/testcases/kernel/controllers/cgroup/cgroup_core02.c
+++ b/testcases/kernel/controllers/cgroup/cgroup_core02.c
@@ -51,7 +51,7 @@ static int lesser_ns_open_thread_fn(void *arg)
static void test_lesser_ns_open(void)
{
int i;
- static char stack[65536];
+ char *stack;
pid_t pid;
int status;
struct lesser_ns_open_thread_arg targ = { .fds = {0}, .loops = -1};
@@ -63,14 +63,19 @@ static void test_lesser_ns_open(void)
SAFE_CG_PRINT(cg_child_a, "cgroup.procs", "0");
SAFE_CG_FCHOWN(cg_child_a, "cgroup.procs", nobody_uid, -1);
SAFE_CG_FCHOWN(cg_child_b, "cgroup.procs", nobody_uid, -1);
+ stack = SAFE_MMAP(NULL, 65536, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
pid = ltp_clone(CLONE_NEWCGROUP | CLONE_FILES | CLONE_VM | SIGCHLD,
lesser_ns_open_thread_fn, &targ, 65536, stack);
+
if (pid < 0) {
tst_res(TFAIL, "unexpected negative pid %d", pid);
exit(1);
}
SAFE_WAITPID(pid, &status, 0);
+ SAFE_MUNMAP(stack, 65536);
+
for (i = 0; i < targ.loops; i++) {
if (targ.fds[i] < 1) {
tst_res(TFAIL, "unexpected negative fd %d", targ.fds[i]);
--
2.47.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] cgroup_core02: Allocate child stack using mmap()
2025-01-17 14:48 [LTP] [PATCH] cgroup_core02: Allocate child stack using mmap() Martin Doucha
@ 2025-01-17 15:03 ` Petr Vorel
2025-01-17 16:05 ` Cyril Hrubis
1 sibling, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2025-01-17 15:03 UTC (permalink / raw)
To: Martin Doucha; +Cc: ltp
Hi Martin,
> Some architectures like arm64 have strict requirements for stack alignment.
> Statically allocated buffer may result in one of the test processes
> getting killed by SIGBUS. Allocate child stack using mmap() to ensure
> the requirements are met.
Acked-by: Petr Vorel <pvorel@suse.cz>
LGTM, thanks for fixing this.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] cgroup_core02: Allocate child stack using mmap()
2025-01-17 14:48 [LTP] [PATCH] cgroup_core02: Allocate child stack using mmap() Martin Doucha
2025-01-17 15:03 ` Petr Vorel
@ 2025-01-17 16:05 ` Cyril Hrubis
1 sibling, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2025-01-17 16:05 UTC (permalink / raw)
To: Martin Doucha; +Cc: ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-17 16:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17 14:48 [LTP] [PATCH] cgroup_core02: Allocate child stack using mmap() Martin Doucha
2025-01-17 15:03 ` Petr Vorel
2025-01-17 16:05 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox