Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extending Landlock's tests using relevant io_uring's operations #819

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tools/testing/selftests/landlock/base_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,5 +325,30 @@ TEST(ruleset_fd_transfer)
ASSERT_EQ(1, WIFEXITED(status));
ASSERT_EQ(EXIT_SUCCESS, WEXITSTATUS(status));
}
TEST(io_uring_operations_restricted)
{
int io_uring_fd;
struct io_uring_probe *probe;
int ret;

// Create an io_uring instance
io_uring_fd = io_uring_setup(10, NULL);
ASSERT_NE(-1, io_uring_fd);

// Probe for the availability of specified operations
probe = io_uring_get_probe();
ASSERT_NE(NULL, probe);

// Check if the desired io_uring operations are restricted
ret = io_uring_opcode_supported(probe, IORING_OP_OPENAT);
ASSERT_EQ(0, ret); // IORING_OP_OPENAT should be restricted

ret = io_uring_opcode_supported(probe, IORING_OP_CONNECT);
ASSERT_EQ(0, ret); // IORING_OP_CONNECT should be restricted

// Clean up
io_uring_free_probe(probe);
close(io_uring_fd);
}

TEST_HARNESS_MAIN