mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tahera Fahimi <fahimitahera@gmail.com>
To: outreachy@lists.linux.dev
Cc: mic@digikod.net, 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,
	Tahera Fahimi <fahimitahera@gmail.com>
Subject: [PATCH v11 2/8] selftests/landlock: Add test for handling unknown scope
Date: Wed,  4 Sep 2024 18:13:56 -0600	[thread overview]
Message-ID: <74b363aaa7ddf80e1e5e132ce3d550a3a8bbf6da.1725494372.git.fahimitahera@gmail.com> (raw)
In-Reply-To: <cover.1725494372.git.fahimitahera@gmail.com>

The test function, "ruleset_with_unknown_scope", is designed to validate
the behaviour of the "landlock_create_ruleset" function when it is
provided with an unsupported or unknown scope mask.

Signed-off-by: Tahera Fahimi <fahimitahera@gmail.com>
---
Changes in versions:
v11:
* Change commit subject and apply coding style
---
 .../testing/selftests/landlock/scoped_test.c  | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 tools/testing/selftests/landlock/scoped_test.c

diff --git a/tools/testing/selftests/landlock/scoped_test.c b/tools/testing/selftests/landlock/scoped_test.c
new file mode 100644
index 000000000000..36d7266de9dc
--- /dev/null
+++ b/tools/testing/selftests/landlock/scoped_test.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Landlock tests - Common scope restriction
+ *
+ * Copyright © 2024 Tahera Fahimi <fahimitahera@gmail.com>
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <linux/landlock.h>
+#include <sys/prctl.h>
+
+#include "common.h"
+
+#define ACCESS_LAST LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET
+
+TEST(ruleset_with_unknown_scope)
+{
+	__u64 scoped_mask;
+
+	for (scoped_mask = 1ULL << 63; scoped_mask != ACCESS_LAST;
+	     scoped_mask >>= 1) {
+		struct landlock_ruleset_attr ruleset_attr = {
+			.scoped = scoped_mask,
+		};
+
+		ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr,
+						      sizeof(ruleset_attr), 0));
+		ASSERT_EQ(EINVAL, errno);
+	}
+}
+
+TEST_HARNESS_MAIN
-- 
2.34.1


  parent reply	other threads:[~2024-09-05  0:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05  0:13 [PATCH v11 0/8] Landlock: Add abstract UNIX socket restriction Tahera Fahimi
2024-09-05  0:13 ` [PATCH v11 1/8] " Tahera Fahimi
2024-09-13 10:46   ` Mickaël Salaün
2024-09-13 13:32   ` Mickaël Salaün
2024-09-16 12:32     ` Tahera Fahimi
2024-09-05  0:13 ` Tahera Fahimi [this message]
2024-09-05  0:13 ` [PATCH v11 3/8] selftests/landlock: Add abstract UNIX socket restriction tests Tahera Fahimi
2024-09-05  0:13 ` [PATCH v11 4/8] selftests/landlock: Add tests for UNIX sockets with any address formats Tahera Fahimi
2024-09-05  0:13 ` [PATCH v11 5/8] selftests/landlock: Test connected vs non-connected datagram UNIX socket Tahera Fahimi
2024-09-05  0:14 ` [PATCH v11 6/8] selftests/landlock: Restrict inherited datagram UNIX socket to connect Tahera Fahimi
2024-09-05  0:14 ` [PATCH v11 7/8] sample/landlock: Add support abstract UNIX socket restriction Tahera Fahimi
2024-09-05  0:14 ` [PATCH v11 8/8] Landlock: Document LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET and ABI version Tahera Fahimi
2024-09-13 16:33 ` [PATCH v11 0/8] Landlock: Add abstract UNIX socket restriction Mickaël Salaün
2024-09-13 17:39   ` Mickaël Salaün

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=74b363aaa7ddf80e1e5e132ce3d550a3a8bbf6da.1725494372.git.fahimitahera@gmail.com \
    --to=fahimitahera@gmail.com \
    --cc=bjorn3_gh@protonmail.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=mic@digikod.net \
    --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

all inboxes | Powered by JetHome®