Skip to content

Commit bf9f14c

Browse files
goongascschaufler
authored andcommitted
smack: remove /smack/logging if audit is not configured
If CONFIG_AUDIT is not set then SMACK does not generate audit messages, however, keeps audit control file, /smack/logging, while there is no entity to control. This change removes audit control file /smack/logging when audit is not configured in the kernel Signed-off-by: Konstantin Andreev <[email protected]> Signed-off-by: Casey Schaufler <[email protected]>
1 parent 6cce0cc commit bf9f14c

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

security/smack/smack.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,19 +432,19 @@ static inline struct smack_known *smk_of_current(void)
432432
return smk_of_task(smack_cred(current_cred()));
433433
}
434434

435+
void smack_log(char *subject_label, char *object_label,
436+
int request,
437+
int result, struct smk_audit_info *auditdata);
438+
439+
#ifdef CONFIG_AUDIT
440+
435441
/*
436442
* logging functions
437443
*/
438444
#define SMACK_AUDIT_DENIED 0x1
439445
#define SMACK_AUDIT_ACCEPT 0x2
440446
extern int log_policy;
441447

442-
void smack_log(char *subject_label, char *object_label,
443-
int request,
444-
int result, struct smk_audit_info *auditdata);
445-
446-
#ifdef CONFIG_AUDIT
447-
448448
/*
449449
* some inline functions to set up audit data
450450
* they do nothing if CONFIG_AUDIT is not set

security/smack/smack_access.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ LIST_HEAD(smack_known_list);
4545
*/
4646
static u32 smack_next_secid = 10;
4747

48+
#ifdef CONFIG_AUDIT
4849
/*
4950
* what events do we log
5051
* can be overwritten at run-time by /smack/logging
5152
*/
5253
int log_policy = SMACK_AUDIT_DENIED;
54+
#endif /* CONFIG_AUDIT */
5355

5456
/**
5557
* smk_access_entry - look up matching access rule

security/smack/smackfs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ enum smk_inos {
4141
SMK_AMBIENT = 7, /* internet ambient label */
4242
SMK_NET4ADDR = 8, /* single label hosts */
4343
SMK_ONLYCAP = 9, /* the only "capable" label */
44+
#ifdef CONFIG_AUDIT
4445
SMK_LOGGING = 10, /* logging */
46+
#endif /* CONFIG_AUDIT */
4547
SMK_LOAD_SELF = 11, /* task specific rules */
4648
SMK_ACCESSES = 12, /* access policy */
4749
SMK_MAPPED = 13, /* CIPSO level indicating mapped label */
@@ -2133,6 +2135,7 @@ static const struct file_operations smk_unconfined_ops = {
21332135
};
21342136
#endif /* CONFIG_SECURITY_SMACK_BRINGUP */
21352137

2138+
#ifdef CONFIG_AUDIT
21362139
/**
21372140
* smk_read_logging - read() for /smack/logging
21382141
* @filp: file pointer, not actually used
@@ -2197,6 +2200,7 @@ static const struct file_operations smk_logging_ops = {
21972200
.write = smk_write_logging,
21982201
.llseek = default_llseek,
21992202
};
2203+
#endif /* CONFIG_AUDIT */
22002204

22012205
/*
22022206
* Seq_file read operations for /smack/load-self
@@ -2883,8 +2887,10 @@ static int smk_fill_super(struct super_block *sb, struct fs_context *fc)
28832887
"netlabel", &smk_net4addr_ops, S_IRUGO|S_IWUSR},
28842888
[SMK_ONLYCAP] = {
28852889
"onlycap", &smk_onlycap_ops, S_IRUGO|S_IWUSR},
2890+
#ifdef CONFIG_AUDIT
28862891
[SMK_LOGGING] = {
28872892
"logging", &smk_logging_ops, S_IRUGO|S_IWUSR},
2893+
#endif /* CONFIG_AUDIT */
28882894
[SMK_LOAD_SELF] = {
28892895
"load-self", &smk_load_self_ops, S_IRUGO|S_IWUGO},
28902896
[SMK_ACCESSES] = {

0 commit comments

Comments
 (0)