From: "Mickaël Salaün" <mic@digikod.net>
To: Tahera Fahimi <fahimitahera@gmail.com>
Cc: outreachy@lists.linux.dev, gnoack@google.com,
paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, bjorn3_gh@protonmail.com,
jannh@google.com, netdev@vger.kernel.org
Subject: Re: [PATCH v3 4/6] selftest/Landlock: pthread_kill(3) tests
Date: Tue, 20 Aug 2024 17:57:07 +0200 [thread overview]
Message-ID: <20240820.eesaifai6Goo@digikod.net> (raw)
In-Reply-To: <f9ddc707873b30f440779feb1f284fc2a4aae40b.1723680305.git.fahimitahera@gmail.com>
Please make sure all subject's prefixes are correct, there is two errors
in the prefix and the description can be made more consistent with other
patches, something like this: "selftests/landlock: Add
signal_scoping_threads test"
On Thu, Aug 15, 2024 at 12:29:23PM -0600, Tahera Fahimi wrote:
> This patch expands the signal scoping tests with pthread_kill(3)
> It tests if an scoped thread can send signal to a process in
> the same scoped domain, or a non-sandboxed thread.
>
> Signed-off-by: Tahera Fahimi <fahimitahera@gmail.com>
> ---
> .../selftests/landlock/scoped_signal_test.c | 29 +++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/tools/testing/selftests/landlock/scoped_signal_test.c b/tools/testing/selftests/landlock/scoped_signal_test.c
> index 92958c6266ca..2edba1e6cd82 100644
> --- a/tools/testing/selftests/landlock/scoped_signal_test.c
> +++ b/tools/testing/selftests/landlock/scoped_signal_test.c
> @@ -10,6 +10,7 @@
> #include <errno.h>
> #include <fcntl.h>
> #include <linux/landlock.h>
> +#include <pthread.h>
> #include <signal.h>
> #include <sys/prctl.h>
> #include <sys/types.h>
> @@ -18,6 +19,7 @@
>
> #include "common.h"
>
> +#define DEFAULT_THREAD_RUNTIME 0.001
> static sig_atomic_t signaled;
>
> static void create_signal_domain(struct __test_metadata *const _metadata)
> @@ -299,4 +301,31 @@ TEST_F(signal_scoping, test_signal)
> _metadata->exit_code = KSFT_FAIL;
> }
>
> +static void *thread_func(void *arg)
> +{
> + sleep(DEFAULT_THREAD_RUNTIME);
Using sleep() may make this test flaky. It needs to be removed and the
test should work the same.
> + return NULL;
> +}
> +
> +TEST(signal_scoping_threads)
> +{
> + pthread_t no_sandbox_thread, scoped_thread;
> + int err;
> +
> + ASSERT_EQ(0,
> + pthread_create(&no_sandbox_thread, NULL, thread_func, NULL));
> + create_signal_domain(_metadata);
> + ASSERT_EQ(0, pthread_create(&scoped_thread, NULL, thread_func, NULL));
> +
> + /* Send signal to threads */
> + err = pthread_kill(no_sandbox_thread, 0);
> + ASSERT_EQ(EPERM, err);
> +
> + err = pthread_kill(scoped_thread, 0);
> + ASSERT_EQ(0, err);
> +
> + ASSERT_EQ(0, pthread_join(scoped_thread, NULL));
> + ASSERT_EQ(0, pthread_join(no_sandbox_thread, NULL));
> +}
> +
> TEST_HARNESS_MAIN
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2024-08-20 15:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 18:29 [PATCH v3 0/6] Landlock: Signal Scoping Support Tahera Fahimi
2024-08-15 18:29 ` [PATCH v3 1/6] Landlock: Add signal control Tahera Fahimi
2024-08-15 18:29 ` [PATCH v3 2/6] Landlock: Adding file_send_sigiotask signal scoping support Tahera Fahimi
2024-08-15 20:25 ` Jann Horn
2024-08-15 21:28 ` Tahera Fahimi
2024-08-15 22:10 ` Jann Horn
2024-08-15 23:06 ` Tahera Fahimi
2024-08-19 17:57 ` Mickaël Salaün
2024-08-21 10:13 ` Mickaël Salaün
2024-08-15 18:29 ` [PATCH v3 3/6] selftest/Landlock: Signal restriction tests Tahera Fahimi
2024-08-20 15:57 ` Mickaël Salaün
2024-08-26 12:40 ` Mickaël Salaün
2024-08-15 18:29 ` [PATCH v3 4/6] selftest/Landlock: pthread_kill(3) tests Tahera Fahimi
2024-08-20 15:57 ` Mickaël Salaün [this message]
2024-08-26 12:40 ` Mickaël Salaün
2024-08-15 18:29 ` [PATCH v3 5/6] sample/Landlock: Support signal scoping restriction Tahera Fahimi
2024-08-15 18:29 ` [PATCH v3 6/6] Landlock: Document LANDLOCK_SCOPED_SIGNAL Tahera Fahimi
2024-08-15 21:07 ` Tahera Fahimi
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=20240820.eesaifai6Goo@digikod.net \
--to=mic@digikod.net \
--cc=bjorn3_gh@protonmail.com \
--cc=fahimitahera@gmail.com \
--cc=gnoack@google.com \
--cc=jannh@google.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=outreachy@lists.linux.dev \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
/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;
as well as URLs for NNTP newsgroup(s).