From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 2/2] Add mseal01 test
Date: Thu, 25 Jul 2024 17:55:24 +0200 [thread overview]
Message-ID: <ZqJ1bKQ4_0GG3r_7@yuki> (raw)
In-Reply-To: <20240723-mseal-v2-2-5aa872d611bc@suse.com>
Hi!
> +static void child(unsigned int n)
> +{
> + struct tcase *tc = &tcases[n];
> +
> + mem_addr = SAFE_MMAP(NULL, mem_size,
> + tc->prot,
> + MAP_ANONYMOUS | MAP_PRIVATE,
> + -1, 0);
> +
> + tst_res(TINFO, "Testing %s", tc->message);
> +
> + TST_EXP_PASS(sys_mseal(mem_addr + mem_offset, mem_alignment));
> +
> + tc->func_test();
> +}
> +
> +static void run(unsigned int n)
> +{
> + /* the reason why we spawn a child is that mseal() will
> + * protect VMA until process will call _exit()
> + */
> + if (!SAFE_FORK()) {
> + child(n);
> + _exit(0);
> + }
> +
> + tst_reap_children();
> +
> + if (mem_addr != MAP_FAILED)
> + SAFE_MUNMAP(mem_addr, mem_size);
The memory is mapped in the child, it's hence not propagated to the
parent. With fork() only changes done in parent before the fork happens
are visible in child as well, since the memory is CoW.
> +}
> +
> +static void setup(void)
> +{
> + mem_alignment = getpagesize();
> + mem_size = mem_alignment * MEMPAGES;
> + mem_offset = mem_alignment * MEMSEAL;
> +}
> +
> +static void cleanup(void)
> +{
> + if (mem_addr != MAP_FAILED)
> + SAFE_MUNMAP(mem_addr, mem_size);
Here as well, this is useless, since the memory was allocated in child,
and freed automatically when the child exits.
The rest look fine.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2024-07-25 15:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 8:41 [LTP] [PATCH v2 0/2] Add mseal() testing suite Andrea Cervesato
2024-07-23 8:41 ` [LTP] [PATCH v2 1/2] Add mseal() syscall declaration Andrea Cervesato
2024-07-24 11:25 ` Cyril Hrubis
2024-07-24 13:58 ` Andrea Cervesato via ltp
2024-07-24 14:58 ` Cyril Hrubis
2024-07-24 15:34 ` Andrea Cervesato via ltp
2024-07-25 15:12 ` Cyril Hrubis
2024-07-23 8:41 ` [LTP] [PATCH v2 2/2] Add mseal01 test Andrea Cervesato
2024-07-25 15:55 ` Cyril Hrubis [this message]
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=ZqJ1bKQ4_0GG3r_7@yuki \
--to=chrubis@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/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