Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d9eb1fb
landlock: Remove warning in collect_domain_accesses()
l0kod Jun 18, 2025
bca3087
selftests/landlock: Add tests for access through disconnected paths
micromaomao Jun 14, 2025
4a2e8dc
landlock: Fix handling of disconnected directories
l0kod Jul 1, 2025
86fdfba
selftests/landlock: Add layout4_disconnected test suite
l0kod Jul 1, 2025
63d2cbb
landlock: Set the max rules limit in a domain to U16_MAX.
micromaomao Jun 29, 2025
eaf2396
landlock/domain: Define structure and macros for flat-array domains
micromaomao Jun 28, 2025
66e0f20
landlock/domain: Implement finding rules
micromaomao Jun 29, 2025
539d31e
landlock/domain: Implement merging walk of a parent domain and a ruleset
micromaomao Jun 29, 2025
6d2b037
landlock/domain: Add KUnit tests for struct landlock_domain
micromaomao Jun 28, 2025
3539767
landlock/domain: Define alloc and free
micromaomao Jun 28, 2025
1ee0b46
landlock/domain: Add landlock_domain_merge_ruleset
micromaomao Jun 28, 2025
975231e
Replace domain in landlock_cred with landlock_domain
micromaomao Jun 29, 2025
d65cee7
Replace landlock_merge_ruleset with landlock_domain_merge_ruleset
micromaomao Jun 29, 2025
11ddf93
landlock: Pull landlock_put_hierarchy out of domain.h
micromaomao Jun 29, 2025
4d06537
landlock: Update uses of landlock_ruleset-domains to landlock_domain
micromaomao Jun 29, 2025
3856771
landlock: Remove unused code
micromaomao Jun 29, 2025
4be249d
squash copilot changes
Copilot Jul 1, 2025
93250db
Fix coalesced hashing implementation and resolve compilation issues
Copilot Jul 5, 2025
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
2 changes: 1 addition & 1 deletion fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ static bool nd_alloc_stack(struct nameidata *nd)
* Rename can sometimes move a file or directory outside of a bind
* mount, path_connected allows those cases to be detected.
*/
static bool path_connected(struct vfsmount *mnt, struct dentry *dentry)
bool path_connected(struct vfsmount *mnt, struct dentry *dentry)
{
struct super_block *sb = mnt->mnt_sb;

Expand Down
1 change: 1 addition & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3252,6 +3252,7 @@ extern struct file * open_exec(const char *);
/* fs/dcache.c -- generic fs support functions */
extern bool is_subdir(struct dentry *, struct dentry *);
extern bool path_is_under(const struct path *, const struct path *);
extern bool path_connected(struct vfsmount *mnt, struct dentry *dentry);

extern char *file_path(struct file *, char *, int);

Expand Down
4 changes: 3 additions & 1 deletion security/landlock/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
obj-$(CONFIG_SECURITY_LANDLOCK) := landlock.o

landlock-y := setup.o syscalls.o object.o ruleset.o \
cred.o task.o fs.o
cred.o task.o fs.o domain.o

landlock-$(CONFIG_INET) += net.o

landlock-$(CONFIG_AUDIT) += \
id.o \
audit.o \
domain.o

landlock-$(CONFIG_SECURITY_LANDLOCK_KUNIT_TEST) += domain_hashtable_tests.o
24 changes: 20 additions & 4 deletions security/landlock/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static void log_domain(struct landlock_hierarchy *const hierarchy)
}

static struct landlock_hierarchy *
get_hierarchy(const struct landlock_ruleset *const domain, const size_t layer)
get_hierarchy(const struct landlock_domain *const domain, const size_t layer)
{
struct landlock_hierarchy *hierarchy = domain->hierarchy;
ssize_t i;
Expand Down Expand Up @@ -167,7 +167,7 @@ static void test_get_hierarchy(struct kunit *const test)
.parent = &dom1_hierarchy,
.id = 30,
};
struct landlock_ruleset dom2 = {
struct landlock_domain dom2 = {
.hierarchy = &dom2_hierarchy,
.num_layers = 3,
};
Expand All @@ -180,7 +180,7 @@ static void test_get_hierarchy(struct kunit *const test)

#endif /* CONFIG_SECURITY_LANDLOCK_KUNIT_TEST */

static size_t get_denied_layer(const struct landlock_ruleset *const domain,
static size_t get_denied_layer(const struct landlock_domain *const domain,
access_mask_t *const access_request,
const layer_mask_t (*const layer_masks)[],
const size_t layer_masks_size)
Expand Down Expand Up @@ -218,7 +218,7 @@ static size_t get_denied_layer(const struct landlock_ruleset *const domain,

static void test_get_denied_layer(struct kunit *const test)
{
const struct landlock_ruleset dom = {
const struct landlock_domain dom = {
.num_layers = 5,
};
const layer_mask_t layer_masks[LANDLOCK_NUM_ACCESS_FS] = {
Expand Down Expand Up @@ -501,6 +501,22 @@ void landlock_log_drop_domain(const struct landlock_hierarchy *const hierarchy)
audit_log_end(ab);
}

deny_masks_t
landlock_get_deny_masks(const access_mask_t all_existing_optional_access,
const access_mask_t optional_access,
const layer_mask_t (*const layer_masks)[],
size_t layer_masks_size)
{
/* Simplified implementation for now - could be enhanced later */
return 0;
}

int landlock_init_hierarchy_log(struct landlock_hierarchy *const hierarchy)
{
/* Simplified implementation for now - could be enhanced later */
return 0;
}

#ifdef CONFIG_SECURITY_LANDLOCK_KUNIT_TEST

static struct kunit_case test_cases[] = {
Expand Down
12 changes: 6 additions & 6 deletions security/landlock/cred.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "common.h"
#include "cred.h"
#include "ruleset.h"
#include "domain.h"
#include "setup.h"

static void hook_cred_transfer(struct cred *const new,
Expand All @@ -23,7 +23,7 @@ static void hook_cred_transfer(struct cred *const new,
landlock_cred(old);

if (old_llcred->domain) {
landlock_get_ruleset(old_llcred->domain);
landlock_get_domain(old_llcred->domain);
*landlock_cred(new) = *old_llcred;
}
}
Expand All @@ -37,10 +37,10 @@ static int hook_cred_prepare(struct cred *const new,

static void hook_cred_free(struct cred *const cred)
{
struct landlock_ruleset *const dom = landlock_cred(cred)->domain;

if (dom)
landlock_put_ruleset_deferred(dom);
/*
* landlock_put_domain_deferred does nothing if domain is NULL
*/
landlock_put_domain_deferred(landlock_cred(cred)->domain);
}

#ifdef CONFIG_AUDIT
Expand Down
14 changes: 7 additions & 7 deletions security/landlock/cred.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "access.h"
#include "limits.h"
#include "ruleset.h"
#include "domain.h"
#include "setup.h"

/**
Expand All @@ -29,9 +29,9 @@
*/
struct landlock_cred_security {
/**
* @domain: Immutable ruleset enforced on a task.
* @domain: Immutable domain enforced on a task.
*/
struct landlock_ruleset *domain;
struct landlock_domain *domain;

#ifdef CONFIG_AUDIT
/**
Expand Down Expand Up @@ -65,15 +65,15 @@ landlock_cred(const struct cred *cred)
return cred->security + landlock_blob_sizes.lbs_cred;
}

static inline struct landlock_ruleset *landlock_get_current_domain(void)
static inline struct landlock_domain *landlock_get_current_domain(void)
{
return landlock_cred(current_cred())->domain;
}

/*
* The call needs to come from an RCU read-side critical section.
*/
static inline const struct landlock_ruleset *
static inline const struct landlock_domain *
landlock_get_task_domain(const struct task_struct *const task)
{
return landlock_cred(__task_cred(task))->domain;
Expand Down Expand Up @@ -114,7 +114,7 @@ landlock_get_applicable_subject(const struct cred *const cred,
const union access_masks_all masks_all = {
.masks = masks,
};
const struct landlock_ruleset *domain;
const struct landlock_domain *domain;
ssize_t layer_level;

if (!cred)
Expand All @@ -127,7 +127,7 @@ landlock_get_applicable_subject(const struct cred *const cred,
for (layer_level = domain->num_layers - 1; layer_level >= 0;
layer_level--) {
union access_masks_all layer = {
.masks = domain->access_masks[layer_level],
.masks = dom_access_masks(domain)[layer_level],
};

if (layer.all & masks_all.all) {
Expand Down
Loading