Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * AppArmor security module
0004  *
0005  * This file contains AppArmor filesystem definitions.
0006  *
0007  * Copyright (C) 1998-2008 Novell/SUSE
0008  * Copyright 2009-2010 Canonical Ltd.
0009  */
0010 
0011 #ifndef __AA_APPARMORFS_H
0012 #define __AA_APPARMORFS_H
0013 
0014 extern struct path aa_null;
0015 
0016 enum aa_sfs_type {
0017     AA_SFS_TYPE_BOOLEAN,
0018     AA_SFS_TYPE_STRING,
0019     AA_SFS_TYPE_U64,
0020     AA_SFS_TYPE_FOPS,
0021     AA_SFS_TYPE_DIR,
0022 };
0023 
0024 struct aa_sfs_entry;
0025 
0026 struct aa_sfs_entry {
0027     const char *name;
0028     struct dentry *dentry;
0029     umode_t mode;
0030     enum aa_sfs_type v_type;
0031     union {
0032         bool boolean;
0033         char *string;
0034         unsigned long u64;
0035         struct aa_sfs_entry *files;
0036     } v;
0037     const struct file_operations *file_ops;
0038 };
0039 
0040 extern const struct file_operations aa_sfs_seq_file_ops;
0041 
0042 #define AA_SFS_FILE_BOOLEAN(_name, _value) \
0043     { .name = (_name), .mode = 0444, \
0044       .v_type = AA_SFS_TYPE_BOOLEAN, .v.boolean = (_value), \
0045       .file_ops = &aa_sfs_seq_file_ops }
0046 #define AA_SFS_FILE_STRING(_name, _value) \
0047     { .name = (_name), .mode = 0444, \
0048       .v_type = AA_SFS_TYPE_STRING, .v.string = (_value), \
0049       .file_ops = &aa_sfs_seq_file_ops }
0050 #define AA_SFS_FILE_U64(_name, _value) \
0051     { .name = (_name), .mode = 0444, \
0052       .v_type = AA_SFS_TYPE_U64, .v.u64 = (_value), \
0053       .file_ops = &aa_sfs_seq_file_ops }
0054 #define AA_SFS_FILE_FOPS(_name, _mode, _fops) \
0055     { .name = (_name), .v_type = AA_SFS_TYPE_FOPS, \
0056       .mode = (_mode), .file_ops = (_fops) }
0057 #define AA_SFS_DIR(_name, _value) \
0058     { .name = (_name), .v_type = AA_SFS_TYPE_DIR, .v.files = (_value) }
0059 
0060 extern void __init aa_destroy_aafs(void);
0061 
0062 struct aa_profile;
0063 struct aa_ns;
0064 
0065 enum aafs_ns_type {
0066     AAFS_NS_DIR,
0067     AAFS_NS_PROFS,
0068     AAFS_NS_NS,
0069     AAFS_NS_RAW_DATA,
0070     AAFS_NS_LOAD,
0071     AAFS_NS_REPLACE,
0072     AAFS_NS_REMOVE,
0073     AAFS_NS_REVISION,
0074     AAFS_NS_COUNT,
0075     AAFS_NS_MAX_COUNT,
0076     AAFS_NS_SIZE,
0077     AAFS_NS_MAX_SIZE,
0078     AAFS_NS_OWNER,
0079     AAFS_NS_SIZEOF,
0080 };
0081 
0082 enum aafs_prof_type {
0083     AAFS_PROF_DIR,
0084     AAFS_PROF_PROFS,
0085     AAFS_PROF_NAME,
0086     AAFS_PROF_MODE,
0087     AAFS_PROF_ATTACH,
0088     AAFS_PROF_HASH,
0089     AAFS_PROF_RAW_DATA,
0090     AAFS_PROF_RAW_HASH,
0091     AAFS_PROF_RAW_ABI,
0092     AAFS_PROF_SIZEOF,
0093 };
0094 
0095 #define ns_dir(X) ((X)->dents[AAFS_NS_DIR])
0096 #define ns_subns_dir(X) ((X)->dents[AAFS_NS_NS])
0097 #define ns_subprofs_dir(X) ((X)->dents[AAFS_NS_PROFS])
0098 #define ns_subdata_dir(X) ((X)->dents[AAFS_NS_RAW_DATA])
0099 #define ns_subload(X) ((X)->dents[AAFS_NS_LOAD])
0100 #define ns_subreplace(X) ((X)->dents[AAFS_NS_REPLACE])
0101 #define ns_subremove(X) ((X)->dents[AAFS_NS_REMOVE])
0102 #define ns_subrevision(X) ((X)->dents[AAFS_NS_REVISION])
0103 
0104 #define prof_dir(X) ((X)->dents[AAFS_PROF_DIR])
0105 #define prof_child_dir(X) ((X)->dents[AAFS_PROF_PROFS])
0106 
0107 void __aa_bump_ns_revision(struct aa_ns *ns);
0108 void __aafs_profile_rmdir(struct aa_profile *profile);
0109 void __aafs_profile_migrate_dents(struct aa_profile *old,
0110                    struct aa_profile *new);
0111 int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent);
0112 void __aafs_ns_rmdir(struct aa_ns *ns);
0113 int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name,
0114              struct dentry *dent);
0115 
0116 struct aa_loaddata;
0117 
0118 #ifdef CONFIG_SECURITY_APPARMOR_EXPORT_BINARY
0119 void __aa_fs_remove_rawdata(struct aa_loaddata *rawdata);
0120 int __aa_fs_create_rawdata(struct aa_ns *ns, struct aa_loaddata *rawdata);
0121 #else
0122 static inline void __aa_fs_remove_rawdata(struct aa_loaddata *rawdata)
0123 {
0124     /* empty stub */
0125 }
0126 
0127 static inline int __aa_fs_create_rawdata(struct aa_ns *ns,
0128                      struct aa_loaddata *rawdata)
0129 {
0130     return 0;
0131 }
0132 #endif /* CONFIG_SECURITY_APPARMOR_EXPORT_BINARY */
0133 
0134 #endif /* __AA_APPARMORFS_H */