tools/testing/selftests/landlock/scoped_test.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/landlock/scoped_test.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/landlock/scoped_test.c
Extension
.c
Size
676 bytes
Lines
34
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

// 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_SCOPE_SIGNAL

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

Annotation

Implementation Notes