what's going on with aa_destroy_aafs() call in apparmor_init()?
Subsystems (2)
Al Viro
maintainer Correct me if I'm wrong, but as far as I can tell apparmor_init()
ends up being called from security_init(), which is called before the call of vfs_caches_init(), not to mention fs_initcall stuff.
If that's the case, what is this doing there?
error:
aa_destroy_aafs();
AA_ERROR("Error creating AppArmor securityfs\n");
return error;aa_create_aafs() is called via fs_initcall; moreover, it will bail out if called before apparmor_initialized has become true, so...
While we are at it, what will happen if apparmor_init() succeeds, but aa_create_fs() fails afterwards?
If nothing else, aa_null_path will be left {NULL, NULL}, which will immediately oops dentry_open() in aa_inherit_files()...
Quoted 3 lines · Al Viro
Correct me if I'm wrong, but as far as I can tell
apparmor_init()
ends up being called fromsecurity_init(), which is called before the call ofvfs_caches_init(), not to mentionfs_initcallstuff.
sigh, yes that is what is happening.
Quoted 5 lines
If that's the case, what is this doing there?
error:aa_destroy_aafs(); AA_ERROR("Error creating AppArmor securityfs\n"); return error;
it shouldn't be it should have been dropped ages ago. Its a mess up on a patch and then it just got carried forward
Quoted 5 lines
aa_create_aafs()is called viafs_initcall; moreover, it will bail out if called beforeapparmor_initializedhas become true, so...While we are at it, what will happen if
apparmor_init()succeeds, butaa_create_fs()fails afterwards?
Yeah that one is ugly. I will have to poke at the best solution atm. For current kernels, no policy will load. Backing out the LSM hooks isn't going to happen but we will need to just run in an unconfined state and make sure any references to the fs handle the null condition.
Quoted 2 lines
If nothing else,
aa_null_pathwill be left {NULL, NULL}, which will immediately oopsdentry_open()inaa_inherit_files()...
indeed, I have to wonder if it was always that way or I just messed up. I borrowed the pattern from selinux but should have also dug into what it was doing.
regardless it needs to be fixed.
We can check that its null and set the file to null for replace fds.
Give me a bit to see about some patches.