Path: blob/master/security/apparmor/include/apparmorfs.h
26444 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* AppArmor security module3*4* This file contains AppArmor filesystem definitions.5*6* Copyright (C) 1998-2008 Novell/SUSE7* Copyright 2009-2010 Canonical Ltd.8*/910#ifndef __AA_APPARMORFS_H11#define __AA_APPARMORFS_H1213extern struct path aa_null;1415enum aa_sfs_type {16AA_SFS_TYPE_BOOLEAN,17AA_SFS_TYPE_STRING,18AA_SFS_TYPE_U64,19AA_SFS_TYPE_FOPS,20AA_SFS_TYPE_DIR,21};2223struct aa_sfs_entry;2425struct aa_sfs_entry {26const char *name;27struct dentry *dentry;28umode_t mode;29enum aa_sfs_type v_type;30union {31bool boolean;32char *string;33unsigned long u64;34struct aa_sfs_entry *files;35} v;36const struct file_operations *file_ops;37};3839extern const struct file_operations aa_sfs_seq_file_ops;4041#define AA_SFS_FILE_BOOLEAN(_name, _value) \42{ .name = (_name), .mode = 0444, \43.v_type = AA_SFS_TYPE_BOOLEAN, .v.boolean = (_value), \44.file_ops = &aa_sfs_seq_file_ops }45#define AA_SFS_FILE_STRING(_name, _value) \46{ .name = (_name), .mode = 0444, \47.v_type = AA_SFS_TYPE_STRING, .v.string = (_value), \48.file_ops = &aa_sfs_seq_file_ops }49#define AA_SFS_FILE_U64(_name, _value) \50{ .name = (_name), .mode = 0444, \51.v_type = AA_SFS_TYPE_U64, .v.u64 = (_value), \52.file_ops = &aa_sfs_seq_file_ops }53#define AA_SFS_FILE_FOPS(_name, _mode, _fops) \54{ .name = (_name), .v_type = AA_SFS_TYPE_FOPS, \55.mode = (_mode), .file_ops = (_fops) }56#define AA_SFS_DIR(_name, _value) \57{ .name = (_name), .v_type = AA_SFS_TYPE_DIR, .v.files = (_value) }5859extern void __init aa_destroy_aafs(void);6061struct aa_profile;62struct aa_ns;6364enum aafs_ns_type {65AAFS_NS_DIR,66AAFS_NS_PROFS,67AAFS_NS_NS,68AAFS_NS_RAW_DATA,69AAFS_NS_LOAD,70AAFS_NS_REPLACE,71AAFS_NS_REMOVE,72AAFS_NS_REVISION,73AAFS_NS_COUNT,74AAFS_NS_MAX_COUNT,75AAFS_NS_SIZE,76AAFS_NS_MAX_SIZE,77AAFS_NS_OWNER,78AAFS_NS_SIZEOF,79};8081enum aafs_prof_type {82AAFS_PROF_DIR,83AAFS_PROF_PROFS,84AAFS_PROF_NAME,85AAFS_PROF_MODE,86AAFS_PROF_ATTACH,87AAFS_PROF_HASH,88AAFS_PROF_RAW_DATA,89AAFS_PROF_RAW_HASH,90AAFS_PROF_RAW_ABI,91AAFS_PROF_SIZEOF,92};9394#define ns_dir(X) ((X)->dents[AAFS_NS_DIR])95#define ns_subns_dir(X) ((X)->dents[AAFS_NS_NS])96#define ns_subprofs_dir(X) ((X)->dents[AAFS_NS_PROFS])97#define ns_subdata_dir(X) ((X)->dents[AAFS_NS_RAW_DATA])98#define ns_subload(X) ((X)->dents[AAFS_NS_LOAD])99#define ns_subreplace(X) ((X)->dents[AAFS_NS_REPLACE])100#define ns_subremove(X) ((X)->dents[AAFS_NS_REMOVE])101#define ns_subrevision(X) ((X)->dents[AAFS_NS_REVISION])102103#define prof_dir(X) ((X)->dents[AAFS_PROF_DIR])104#define prof_child_dir(X) ((X)->dents[AAFS_PROF_PROFS])105106void __aa_bump_ns_revision(struct aa_ns *ns);107void __aafs_profile_rmdir(struct aa_profile *profile);108void __aafs_profile_migrate_dents(struct aa_profile *old,109struct aa_profile *new);110int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent);111void __aafs_ns_rmdir(struct aa_ns *ns);112int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name,113struct dentry *dent);114115struct aa_loaddata;116117#ifdef CONFIG_SECURITY_APPARMOR_EXPORT_BINARY118void __aa_fs_remove_rawdata(struct aa_loaddata *rawdata);119int __aa_fs_create_rawdata(struct aa_ns *ns, struct aa_loaddata *rawdata);120#else121static inline void __aa_fs_remove_rawdata(struct aa_loaddata *rawdata)122{123/* empty stub */124}125126static inline int __aa_fs_create_rawdata(struct aa_ns *ns,127struct aa_loaddata *rawdata)128{129return 0;130}131#endif /* CONFIG_SECURITY_APPARMOR_EXPORT_BINARY */132133#endif /* __AA_APPARMORFS_H */134135136