| 1 |
|
| 2 | |
| 3 | * AppArmor security module
|
| 4 | *
|
| 5 | * This file contains AppArmor filesystem definitions.
|
| 6 | *
|
| 7 | * Copyright (C) 1998-2008 Novell/SUSE
|
| 8 | * Copyright 2009-2010 Canonical Ltd.
|
| 9 |
|
| 10 |
|
| 11 | #ifndef __AA_APPARMORFS_H
|
| 12 | #define __AA_APPARMORFS_H
|
| 13 |
|
| 14 | #include <linux/init.h>
|
| 15 | #include <linux/types.h>
|
| 16 |
|
| 17 | extern struct path aa_null;
|
| 18 |
|
| 19 | enum aa_sfs_type {
|
| 20 | AA_SFS_TYPE_BOOLEAN,
|
| 21 | AA_SFS_TYPE_STRING,
|
| 22 | AA_SFS_TYPE_U64,
|
| 23 | AA_SFS_TYPE_FOPS,
|
| 24 | AA_SFS_TYPE_DIR,
|
| 25 | };
|
| 26 |
|
| 27 | struct aa_sfs_entry;
|
| 28 |
|
| 29 | struct aa_sfs_entry {
|
| 30 | const char *name;
|
| 31 | struct dentry *dentry;
|
| 32 | umode_t mode;
|
| 33 | enum aa_sfs_type v_type;
|
| 34 | union {
|
| 35 | bool boolean;
|
| 36 | char *string;
|
| 37 | unsigned long u64;
|
| 38 | struct aa_sfs_entry *files;
|
| 39 | } v;
|
| 40 | const struct file_operations *file_ops;
|
| 41 | };
|
| 42 |
|
| 43 | extern const struct file_operations aa_sfs_seq_file_ops;
|
| 44 |
|
| 45 | #define AA_SFS_FILE_BOOLEAN(_name, _value) \
|
| 46 | { .name = (_name), .mode = 0444, \
|
| 47 | .v_type = AA_SFS_TYPE_BOOLEAN, .v.boolean = (_value), \
|
| 48 | .file_ops = &aa_sfs_seq_file_ops }
|
| 49 | #define AA_SFS_FILE_STRING(_name, _value) \
|
| 50 | { .name = (_name), .mode = 0444, \
|
| 51 | .v_type = AA_SFS_TYPE_STRING, .v.string = (_value), \
|
| 52 | .file_ops = &aa_sfs_seq_file_ops }
|
| 53 | #define AA_SFS_FILE_U64(_name, _value) \
|
| 54 | { .name = (_name), .mode = 0444, \
|
| 55 | .v_type = AA_SFS_TYPE_U64, .v.u64 = (_value), \
|
| 56 | .file_ops = &aa_sfs_seq_file_ops }
|
| 57 | #define AA_SFS_FILE_FOPS(_name, _mode, _fops) \
|
| 58 | { .name = (_name), .v_type = AA_SFS_TYPE_FOPS, \
|
| 59 | .mode = (_mode), .file_ops = (_fops) }
|
| 60 | #define AA_SFS_DIR(_name, _value) \
|
| 61 | { .name = (_name), .v_type = AA_SFS_TYPE_DIR, .v.files = (_value) }
|
| 62 |
|
| 63 | extern void __init aa_destroy_aafs(void);
|
| 64 |
|
| 65 | struct aa_profile;
|
| 66 | struct aa_ns;
|
| 67 |
|
| 68 | enum aafs_ns_type {
|
| 69 | AAFS_NS_DIR,
|
| 70 | AAFS_NS_PROFS,
|
| 71 | AAFS_NS_NS,
|
| 72 | AAFS_NS_RAW_DATA,
|
| 73 | AAFS_NS_LOAD,
|
| 74 | AAFS_NS_REPLACE,
|
| 75 | AAFS_NS_REMOVE,
|
| 76 | AAFS_NS_REVISION,
|
| 77 | AAFS_NS_COUNT,
|
| 78 | AAFS_NS_MAX_COUNT,
|
| 79 | AAFS_NS_SIZE,
|
| 80 | AAFS_NS_MAX_SIZE,
|
| 81 | AAFS_NS_OWNER,
|
| 82 | AAFS_NS_SIZEOF,
|
| 83 | };
|
| 84 |
|
| 85 | enum aafs_prof_type {
|
| 86 | AAFS_PROF_DIR,
|
| 87 | AAFS_PROF_PROFS,
|
| 88 | AAFS_PROF_NAME,
|
| 89 | AAFS_PROF_MODE,
|
| 90 | AAFS_PROF_ATTACH,
|
| 91 | AAFS_PROF_HASH,
|
| 92 | AAFS_PROF_RAW_DATA,
|
| 93 | AAFS_PROF_RAW_HASH,
|
| 94 | AAFS_PROF_RAW_ABI,
|
| 95 | AAFS_PROF_SIZEOF,
|
| 96 | };
|
| 97 |
|
| 98 | #define ns_dir(X) ((X)->dents[AAFS_NS_DIR])
|
| 99 | #define ns_subns_dir(X) ((X)->dents[AAFS_NS_NS])
|
| 100 | #define ns_subprofs_dir(X) ((X)->dents[AAFS_NS_PROFS])
|
| 101 | #define ns_subdata_dir(X) ((X)->dents[AAFS_NS_RAW_DATA])
|
| 102 | #define ns_subload(X) ((X)->dents[AAFS_NS_LOAD])
|
| 103 | #define ns_subreplace(X) ((X)->dents[AAFS_NS_REPLACE])
|
| 104 | #define ns_subremove(X) ((X)->dents[AAFS_NS_REMOVE])
|
| 105 | #define ns_subrevision(X) ((X)->dents[AAFS_NS_REVISION])
|
| 106 |
|
| 107 | #define prof_dir(X) ((X)->dents[AAFS_PROF_DIR])
|
| 108 | #define prof_child_dir(X) ((X)->dents[AAFS_PROF_PROFS])
|
| 109 |
|
| 110 | int aa_create_aafs(void);
|
| 111 |
|
| 112 | void __aa_bump_ns_revision(struct aa_ns *ns);
|
| 113 | void __aafs_profile_rmdir(struct aa_profile *profile);
|
| 114 | void __aafs_profile_migrate_dents(struct aa_profile *old,
|
| 115 | struct aa_profile *new);
|
| 116 | int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent);
|
| 117 | void __aafs_ns_rmdir(struct aa_ns *ns);
|
| 118 | int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name,
|
| 119 | struct dentry *dent);
|
| 120 |
|
| 121 | struct aa_loaddata;
|
| 122 |
|
| 123 | #ifdef CONFIG_SECURITY_APPARMOR_EXPORT_BINARY
|
| 124 | void __aa_fs_remove_rawdata(struct aa_loaddata *rawdata);
|
| 125 | int __aa_fs_create_rawdata(struct aa_ns *ns, struct aa_loaddata *rawdata);
|
| 126 | void __aa_remove_rawdata_symlink_dents(struct aa_profile *profile);
|
| 127 | int __aa_create_rawdata_symlink_dents(struct aa_profile *profile);
|
| 128 | #else
|
| 129 | static inline void __aa_fs_remove_rawdata(struct aa_loaddata *rawdata)
|
| 130 | {
|
| 131 |
|
| 132 | }
|
| 133 |
|
| 134 | static inline int __aa_fs_create_rawdata(struct aa_ns *ns,
|
| 135 | struct aa_loaddata *rawdata)
|
| 136 | {
|
| 137 | return 0;
|
| 138 | }
|
| 139 |
|
| 140 | static inline void __aa_remove_rawdata_symlink_dents(struct aa_profile *profile)
|
| 141 | {
|
| 142 |
|
| 143 | }
|
| 144 |
|
| 145 | static inline int __aa_create_rawdata_symlink_dents(struct aa_profile *profile)
|
| 146 | {
|
| 147 | return 0;
|
| 148 | }
|
| 149 | #endif
|
| 150 |
|
| 151 | #endif
|