linux/security/apparmor/include/file.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * AppArmor security module
 *
 * This file contains AppArmor file mediation function definitions.
 *
 * Copyright (C) 1998-2008 Novell/SUSE
 * Copyright 2009-2010 Canonical Ltd.
 */

#ifndef __AA_FILE_H
#define __AA_FILE_H

#include <linux/spinlock.h>

#include "domain.h"
#include "match.h"
#include "perms.h"

struct aa_policydb;
struct aa_profile;
struct path;

#define mask_mode_t(X)

#define AA_AUDIT_FILE_MASK

static inline struct aa_file_ctx *file_ctx(struct file *file)
{}

/* struct aa_file_ctx - the AppArmor context the file was opened in
 * @lock: lock to update the ctx
 * @label: label currently cached on the ctx
 * @perms: the permission the file was opened with
 */
struct aa_file_ctx {};

/*
 * The xindex is broken into 3 parts
 * - index - an index into either the exec name table or the variable table
 * - exec type - which determines how the executable name and index are used
 * - flags - which modify how the destination name is applied
 */
#define AA_X_INDEX_MASK

#define AA_X_TYPE_MASK
#define AA_X_NONE
#define AA_X_NAME
#define AA_X_TABLE

#define AA_X_UNSAFE
#define AA_X_CHILD
#define AA_X_INHERIT
#define AA_X_UNCONFINED

/* need to make conditional which ones are being set */
struct path_cond {};

#define COMBINED_PERM_MASK(X)

int aa_audit_file(const struct cred *cred,
		  struct aa_profile *profile, struct aa_perms *perms,
		  const char *op, u32 request, const char *name,
		  const char *target, struct aa_label *tlabel, kuid_t ouid,
		  const char *info, int error);

struct aa_perms *aa_lookup_fperms(struct aa_policydb *file_rules,
				  aa_state_t state, struct path_cond *cond);
aa_state_t aa_str_perms(struct aa_policydb *file_rules, aa_state_t start,
			const char *name, struct path_cond *cond,
			struct aa_perms *perms);

int aa_path_perm(const char *op, const struct cred *subj_cred,
		 struct aa_label *label, const struct path *path,
		 int flags, u32 request, struct path_cond *cond);

int aa_path_link(const struct cred *subj_cred, struct aa_label *label,
		 struct dentry *old_dentry, const struct path *new_dir,
		 struct dentry *new_dentry);

int aa_file_perm(const char *op, const struct cred *subj_cred,
		 struct aa_label *label, struct file *file,
		 u32 request, bool in_atomic);

void aa_inherit_files(const struct cred *cred, struct files_struct *files);


/**
 * aa_map_file_perms - map file flags to AppArmor permissions
 * @file: open file to map flags to AppArmor permissions
 *
 * Returns: apparmor permission set for the file
 */
static inline u32 aa_map_file_to_perms(struct file *file)
{}

#endif /* __AA_FILE_H */