aboutsummaryrefslogtreecommitdiffstats
path: root/security/apparmor/apparmorfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/apparmor/apparmorfs.c')
-rw-r--r--security/apparmor/apparmorfs.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index d708a55d072f..95c2b2689a03 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -26,6 +26,7 @@
26#include "include/apparmorfs.h" 26#include "include/apparmorfs.h"
27#include "include/audit.h" 27#include "include/audit.h"
28#include "include/context.h" 28#include "include/context.h"
29#include "include/crypto.h"
29#include "include/policy.h" 30#include "include/policy.h"
30#include "include/resource.h" 31#include "include/resource.h"
31 32
@@ -319,6 +320,34 @@ static const struct file_operations aa_fs_profattach_fops = {
319 .release = aa_fs_seq_profile_release, 320 .release = aa_fs_seq_profile_release,
320}; 321};
321 322
323static int aa_fs_seq_hash_show(struct seq_file *seq, void *v)
324{
325 struct aa_replacedby *r = seq->private;
326 struct aa_profile *profile = aa_get_profile_rcu(&r->profile);
327 unsigned int i, size = aa_hash_size();
328
329 if (profile->hash) {
330 for (i = 0; i < size; i++)
331 seq_printf(seq, "%.2x", profile->hash[i]);
332 seq_puts(seq, "\n");
333 }
334
335 return 0;
336}
337
338static int aa_fs_seq_hash_open(struct inode *inode, struct file *file)
339{
340 return single_open(file, aa_fs_seq_hash_show, inode->i_private);
341}
342
343static const struct file_operations aa_fs_seq_hash_fops = {
344 .owner = THIS_MODULE,
345 .open = aa_fs_seq_hash_open,
346 .read = seq_read,
347 .llseek = seq_lseek,
348 .release = single_release,
349};
350
322/** fns to setup dynamic per profile/namespace files **/ 351/** fns to setup dynamic per profile/namespace files **/
323void __aa_fs_profile_rmdir(struct aa_profile *profile) 352void __aa_fs_profile_rmdir(struct aa_profile *profile)
324{ 353{
@@ -420,6 +449,14 @@ int __aa_fs_profile_mkdir(struct aa_profile *profile, struct dentry *parent)
420 goto fail; 449 goto fail;
421 profile->dents[AAFS_PROF_ATTACH] = dent; 450 profile->dents[AAFS_PROF_ATTACH] = dent;
422 451
452 if (profile->hash) {
453 dent = create_profile_file(dir, "sha1", profile,
454 &aa_fs_seq_hash_fops);
455 if (IS_ERR(dent))
456 goto fail;
457 profile->dents[AAFS_PROF_HASH] = dent;
458 }
459
423 list_for_each_entry(child, &profile->base.profiles, base.list) { 460 list_for_each_entry(child, &profile->base.profiles, base.list) {
424 error = __aa_fs_profile_mkdir(child, prof_child_dir(profile)); 461 error = __aa_fs_profile_mkdir(child, prof_child_dir(profile));
425 if (error) 462 if (error)