Skip to content

Commit 7cbe113

Browse files
committed
apparmor: move initcalls to the LSM framework
Reviewed-by: Kees Cook <kees@kernel.org> Acked-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent d3ba8f8 commit 7cbe113

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

security/apparmor/apparmorfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,7 +2649,7 @@ static const struct inode_operations policy_link_iops = {
26492649
*
26502650
* Returns: error on failure
26512651
*/
2652-
static int __init aa_create_aafs(void)
2652+
int __init aa_create_aafs(void)
26532653
{
26542654
struct dentry *dent;
26552655
int error;
@@ -2728,5 +2728,3 @@ static int __init aa_create_aafs(void)
27282728
AA_ERROR("Error creating AppArmor securityfs\n");
27292729
return error;
27302730
}
2731-
2732-
fs_initcall(aa_create_aafs);

security/apparmor/crypto.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start,
5353
return 0;
5454
}
5555

56-
static int __init init_profile_hash(void)
56+
int __init init_profile_hash(void)
5757
{
5858
if (apparmor_initialized)
5959
aa_info_message("AppArmor sha256 policy hashing enabled");
6060
return 0;
6161
}
62-
late_initcall(init_profile_hash);

security/apparmor/include/apparmorfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ enum aafs_prof_type {
104104
#define prof_dir(X) ((X)->dents[AAFS_PROF_DIR])
105105
#define prof_child_dir(X) ((X)->dents[AAFS_PROF_PROFS])
106106

107+
int aa_create_aafs(void);
108+
107109
void __aa_bump_ns_revision(struct aa_ns *ns);
108110
void __aafs_profile_rmdir(struct aa_profile *profile);
109111
void __aafs_profile_migrate_dents(struct aa_profile *old,

security/apparmor/include/crypto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "policy.h"
1414

1515
#ifdef CONFIG_SECURITY_APPARMOR_HASH
16+
int init_profile_hash(void);
1617
unsigned int aa_hash_size(void);
1718
char *aa_calc_hash(void *data, size_t len);
1819
int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start,

security/apparmor/lsm.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "include/audit.h"
3333
#include "include/capability.h"
3434
#include "include/cred.h"
35+
#include "include/crypto.h"
3536
#include "include/file.h"
3637
#include "include/ipc.h"
3738
#include "include/net.h"
@@ -2426,7 +2427,6 @@ static int __init apparmor_nf_ip_init(void)
24262427

24272428
return 0;
24282429
}
2429-
__initcall(apparmor_nf_ip_init);
24302430
#endif
24312431

24322432
static char nulldfa_src[] __aligned(8) = {
@@ -2560,4 +2560,11 @@ DEFINE_LSM(apparmor) = {
25602560
.enabled = &apparmor_enabled,
25612561
.blobs = &apparmor_blob_sizes,
25622562
.init = apparmor_init,
2563+
.initcall_fs = aa_create_aafs,
2564+
#if defined(CONFIG_NETFILTER) && defined(CONFIG_NETWORK_SECMARK)
2565+
.initcall_device = apparmor_nf_ip_init,
2566+
#endif
2567+
#ifdef CONFIG_SECURITY_APPARMOR_HASH
2568+
.initcall_late = init_profile_hash,
2569+
#endif
25632570
};

0 commit comments

Comments
 (0)