Skip to content

Commit 84f1f78

Browse files
committed
apparmor: export set of capabilities supported by the apparmor module
Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com>
1 parent 29b3822 commit 84f1f78

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎security/apparmor/Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ quiet_cmd_make-caps = GEN $@
1818
cmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\
1919
sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \
2020
-e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\
21-
echo "};" >> $@
21+
echo "};" >> $@ ;\
22+
echo -n '\#define AA_FS_CAPS_MASK "' >> $@ ;\
23+
sed $< -r -n -e '/CAP_FS_MASK/d' \
24+
-e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/\L\1/p' | \
25+
tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@
2226

2327

2428
# Build a lower case string table of rlimit names.

‎security/apparmor/apparmorfs.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ static struct aa_fs_entry aa_fs_entry_features[] = {
773773
AA_FS_DIR("file", aa_fs_entry_file),
774774
AA_FS_FILE_U64("capability", VFS_CAP_FLAGS_MASK),
775775
AA_FS_DIR("rlimit", aa_fs_entry_rlimit),
776+
AA_FS_DIR("caps", aa_fs_entry_caps),
776777
{ }
777778
};
778779

‎security/apparmor/capability.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
*/
2828
#include "capability_names.h"
2929

30+
struct aa_fs_entry aa_fs_entry_caps[] = {
31+
AA_FS_FILE_STRING("mask", AA_FS_CAPS_MASK),
32+
{ }
33+
};
34+
3035
struct audit_cache {
3136
struct aa_profile *profile;
3237
kernel_cap_t caps;

‎security/apparmor/include/capability.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include <linux/sched.h>
1919

20+
#include "apparmorfs.h"
21+
2022
struct aa_profile;
2123

2224
/* aa_caps - confinement data for capabilities
@@ -34,6 +36,8 @@ struct aa_caps {
3436
kernel_cap_t extended;
3537
};
3638

39+
extern struct aa_fs_entry aa_fs_entry_caps[];
40+
3741
int aa_capable(struct task_struct *task, struct aa_profile *profile, int cap,
3842
int audit);
3943

0 commit comments

Comments
 (0)