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

Dynamic Landlock ABI configuration wrt. runtime kernel #2263

Open
wants to merge 7 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
23 changes: 16 additions & 7 deletions core/parachain/pvf/kagome_pvf_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ namespace kagome::parachain {

auto abi = ::syscall(
SYS_landlock_create_ruleset, NULL, 0, LANDLOCK_CREATE_RULESET_VERSION);
auto logger = log::createLogger("Landlock", "parachain");
SL_INFO(logger, "Landlock ABI version: {} ", abi);
if (abi < 0) {
return getLastErr("landlock_create_ruleset");
}
Expand All @@ -172,19 +174,26 @@ namespace kagome::parachain {
| LANDLOCK_ACCESS_FS_MAKE_CHAR | LANDLOCK_ACCESS_FS_MAKE_DIR
| LANDLOCK_ACCESS_FS_MAKE_REG | LANDLOCK_ACCESS_FS_MAKE_SOCK
| LANDLOCK_ACCESS_FS_MAKE_FIFO | LANDLOCK_ACCESS_FS_MAKE_BLOCK
| LANDLOCK_ACCESS_FS_MAKE_SYM
| LANDLOCK_ACCESS_FS_MAKE_SYM};

// only add Landlock V2+ features if defined and supported by the (runtime)
// kernel
#ifdef LANDLOCK_ACCESS_FS_REFER
| LANDLOCK_ACCESS_FS_REFER
if (abi >= 2) {
ruleset_attr.handled_access_fs |= LANDLOCK_ACCESS_FS_REFER;
}
#endif
#ifdef LANDLOCK_ACCESS_FS_TRUNCATE
| LANDLOCK_ACCESS_FS_TRUNCATE
if (abi >= 3) {
ruleset_attr.handled_access_fs |= LANDLOCK_ACCESS_FS_TRUNCATE;
}
#endif
,
#ifdef LANDLOCK_ACCESS_NET_CONNECT_TCP
.handled_access_net =
LANDLOCK_ACCESS_NET_BIND_TCP | LANDLOCK_ACCESS_NET_CONNECT_TCP,
if (abi >= 4) {
ruleset_attr.handled_access_net =
LANDLOCK_ACCESS_NET_BIND_TCP | LANDLOCK_ACCESS_NET_CONNECT_TCP;
}
#endif
};

auto ruleset_fd = ::syscall(
SYS_landlock_create_ruleset, &ruleset_attr, sizeof(ruleset_attr), 0);
Expand Down
Loading