17 #include <linux/module.h>
21 #include <linux/capability.h>
25 #include "include/audit.h"
41 static char *aa_simple_write_to_buffer(
int op,
const char __user *userbuf,
42 size_t alloc_size,
size_t copy_size,
47 BUG_ON(copy_size > alloc_size);
81 data = aa_simple_write_to_buffer(
OP_PROF_LOAD, buf, size, size, pos);
83 error = PTR_ERR(data);
93 .write = profile_load,
98 static ssize_t profile_replace(
struct file *f,
const char __user *buf,
99 size_t size, loff_t *pos)
104 data = aa_simple_write_to_buffer(
OP_PROF_REPL, buf, size, size, pos);
105 error = PTR_ERR(data);
115 .write = profile_replace,
120 static ssize_t profile_remove(
struct file *f,
const char __user *buf,
121 size_t size, loff_t *pos)
130 data = aa_simple_write_to_buffer(
OP_PROF_RM, buf, size + 1, size, pos);
132 error = PTR_ERR(data);
143 .write = profile_remove,
147 static int aa_fs_seq_show(
struct seq_file *seq,
void *
v)
154 switch (fs_file->
v_type) {
179 .open = aa_fs_seq_open,
201 static struct aa_fs_entry aa_fs_entry_features[] = {
209 static struct aa_fs_entry aa_fs_entry_apparmor[] = {
213 AA_FS_DIR(
"features", aa_fs_entry_features),
218 AA_FS_DIR(
"apparmor", aa_fs_entry_apparmor);
227 static int __init aafs_create_file(
struct aa_fs_entry *fs_file,
236 if (IS_ERR(fs_file->
dentry)) {
237 error = PTR_ERR(fs_file->
dentry);
250 static int __init aafs_create_dir(
struct aa_fs_entry *fs_dir,
254 struct aa_fs_entry *fs_file;
257 if (IS_ERR(fs_dir->
dentry)) {
258 error = PTR_ERR(fs_dir->
dentry);
263 for (fs_file = fs_dir->
v.
files; fs_file->
name; ++fs_file) {
265 error = aafs_create_dir(fs_file, fs_dir->
dentry);
267 error = aafs_create_file(fs_file, fs_dir->
dentry);
282 static void __init aafs_remove_file(
struct aa_fs_entry *fs_file)
295 static void __init aafs_remove_dir(
struct aa_fs_entry *fs_dir)
297 struct aa_fs_entry *fs_file;
299 for (fs_file = fs_dir->
v.
files; fs_file->
name; ++fs_file) {
301 aafs_remove_dir(fs_file);
303 aafs_remove_file(fs_file);
306 aafs_remove_file(fs_dir);
316 aafs_remove_dir(&aa_fs_entry);
326 static int __init aa_create_aafs(
void)
330 if (!apparmor_initialized)
334 AA_ERROR(
"%s: AppArmor securityfs already exists\n", __func__);
339 error = aafs_create_dir(&aa_fs_entry,
NULL);
351 AA_ERROR(
"Error creating AppArmor securityfs\n");