Unverified Commit 06a1c40a authored by Mickaël Salaün's avatar Mickaël Salaün
Browse files

landlock: Format with clang-format

Let's follow a consistent and documented coding style.  Everything may
not be to our liking but it is better than tacit knowledge.  Moreover,
this will help maintain style consistency between different developers.

This contains only whitespace changes.

Automatically formatted with:
clang-format-14 -i security/landlock/*.[ch] include/uapi/linux/landlock.h

Link: https://lore.kernel.org/r/20220506160513.523257-3-mic@digikod.net


Cc: stable@vger.kernel.org
Signed-off-by: default avatarMickaël Salaün <mic@digikod.net>
parent 6cc2df8e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@ struct landlock_cred_security {
	struct landlock_ruleset *domain;
};

static inline struct landlock_cred_security *landlock_cred(
		const struct cred *cred)
static inline struct landlock_cred_security *
landlock_cred(const struct cred *cred)
{
	return cred->security + landlock_blob_sizes.lbs_cred;
}
@@ -34,8 +34,8 @@ static inline const struct landlock_ruleset *landlock_get_current_domain(void)
/*
 * The call needs to come from an RCU read-side critical section.
 */
static inline const struct landlock_ruleset *landlock_get_task_domain(
		const struct task_struct *const task)
static inline const struct landlock_ruleset *
landlock_get_task_domain(const struct task_struct *const task)
{
	return landlock_cred(__task_cred(task))->domain;
}
+40 −38
Original line number Diff line number Diff line
@@ -158,8 +158,8 @@ int landlock_append_fs_rule(struct landlock_ruleset *const ruleset,
	struct landlock_object *object;

	/* Files only get access rights that make sense. */
	if (!d_is_dir(path->dentry) && (access_rights | ACCESS_FILE) !=
			ACCESS_FILE)
	if (!d_is_dir(path->dentry) &&
	    (access_rights | ACCESS_FILE) != ACCESS_FILE)
		return -EINVAL;
	if (WARN_ON_ONCE(ruleset->num_layers != 1))
		return -EINVAL;
@@ -182,10 +182,9 @@ int landlock_append_fs_rule(struct landlock_ruleset *const ruleset,

/* Access-control management */

static inline u64 unmask_layers(
		const struct landlock_ruleset *const domain,
		const struct path *const path, const u32 access_request,
		u64 layer_mask)
static inline u64 unmask_layers(const struct landlock_ruleset *const domain,
				const struct path *const path,
				const u32 access_request, u64 layer_mask)
{
	const struct landlock_rule *rule;
	const struct inode *inode;
@@ -196,8 +195,8 @@ static inline u64 unmask_layers(
		return layer_mask;
	inode = d_backing_inode(path->dentry);
	rcu_read_lock();
	rule = landlock_find_rule(domain,
			rcu_dereference(landlock_inode(inode)->object));
	rule = landlock_find_rule(
		domain, rcu_dereference(landlock_inode(inode)->object));
	rcu_read_unlock();
	if (!rule)
		return layer_mask;
@@ -270,8 +269,8 @@ static int check_access_path(const struct landlock_ruleset *const domain,
	while (true) {
		struct dentry *parent_dentry;

		layer_mask = unmask_layers(domain, &walker_path,
				access_request, layer_mask);
		layer_mask = unmask_layers(domain, &walker_path, access_request,
					   layer_mask);
		if (layer_mask == 0) {
			/* Stops when a rule from each layer grants access. */
			allowed = true;
@@ -438,8 +437,8 @@ static void hook_sb_delete(struct super_block *const sb)
	if (prev_inode)
		iput(prev_inode);
	/* Waits for pending iput() in release_inode(). */
	wait_var_event(&landlock_superblock(sb)->inode_refs, !atomic_long_read(
				&landlock_superblock(sb)->inode_refs));
	wait_var_event(&landlock_superblock(sb)->inode_refs,
		       !atomic_long_read(&landlock_superblock(sb)->inode_refs));
}

/*
@@ -561,7 +560,8 @@ static int hook_path_link(struct dentry *const old_dentry,
		return -EXDEV;
	if (unlikely(d_is_negative(old_dentry)))
		return -ENOENT;
	return check_access_path(dom, new_dir,
	return check_access_path(
		dom, new_dir,
		get_mode_access(d_backing_inode(old_dentry)->i_mode));
}

@@ -590,8 +590,9 @@ static int hook_path_rename(const struct path *const old_dir,
	if (unlikely(d_is_negative(old_dentry)))
		return -ENOENT;
	/* RENAME_EXCHANGE is handled because directories are the same. */
	return check_access_path(dom, old_dir, maybe_remove(old_dentry) |
			maybe_remove(new_dentry) |
	return check_access_path(
		dom, old_dir,
		maybe_remove(old_dentry) | maybe_remove(new_dentry) |
			get_mode_access(d_backing_inode(old_dentry)->i_mode));
}

@@ -614,7 +615,8 @@ static int hook_path_mknod(const struct path *const dir,
}

static int hook_path_symlink(const struct path *const dir,
		struct dentry *const dentry, const char *const old_name)
			     struct dentry *const dentry,
			     const char *const old_name)
{
	return current_check_access_path(dir, LANDLOCK_ACCESS_FS_MAKE_SYM);
}
+6 −5
Original line number Diff line number Diff line
@@ -50,14 +50,14 @@ struct landlock_superblock_security {
	atomic_long_t inode_refs;
};

static inline struct landlock_inode_security *landlock_inode(
		const struct inode *const inode)
static inline struct landlock_inode_security *
landlock_inode(const struct inode *const inode)
{
	return inode->i_security + landlock_blob_sizes.lbs_inode;
}

static inline struct landlock_superblock_security *landlock_superblock(
		const struct super_block *const superblock)
static inline struct landlock_superblock_security *
landlock_superblock(const struct super_block *const superblock)
{
	return superblock->s_security + landlock_blob_sizes.lbs_superblock;
}
@@ -65,6 +65,7 @@ static inline struct landlock_superblock_security *landlock_superblock(
__init void landlock_add_fs_hooks(void);

int landlock_append_fs_rule(struct landlock_ruleset *const ruleset,
		const struct path *const path, u32 access_hierarchy);
			    const struct path *const path,
			    u32 access_hierarchy);

#endif /* _SECURITY_LANDLOCK_FS_H */
+3 −3
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@

#include "object.h"

struct landlock_object *landlock_create_object(
		const struct landlock_object_underops *const underops,
struct landlock_object *
landlock_create_object(const struct landlock_object_underops *const underops,
		       void *const underobj)
{
	struct landlock_object *new_object;
+3 −3
Original line number Diff line number Diff line
@@ -76,8 +76,8 @@ struct landlock_object {
	};
};

struct landlock_object *landlock_create_object(
		const struct landlock_object_underops *const underops,
struct landlock_object *
landlock_create_object(const struct landlock_object_underops *const underops,
		       void *const underobj);

void landlock_put_object(struct landlock_object *const object);
Loading