Skip to content

Commit 9b2eacd

Browse files
committed
Merge tag 'Smack-for-5.15' of git://github.com/cschaufler/smack-next
Pull smack updates from Casey Schaufler: "There is a variable used only during start-up that's now marked __initdata and a change where the code was working by sheer luck that is now done properly. Both have been in next for several weeks and pass the Smack testsuite" * tag 'Smack-for-5.15' of git://github.com/cschaufler/smack-next: smack: mark 'smack_enabled' global variable as __initdata Smack: Fix wrong semantics in smk_access_entry()
2 parents 8e0cd95 + bfc3cac commit 9b2eacd

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

security/smack/smack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ int smack_populate_secattr(struct smack_known *skp);
302302
/*
303303
* Shared data.
304304
*/
305-
extern int smack_enabled;
305+
extern int smack_enabled __initdata;
306306
extern int smack_cipso_direct;
307307
extern int smack_cipso_mapped;
308308
extern struct smack_known *smack_net_ambient;

security/smack/smack_access.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,22 @@ int log_policy = SMACK_AUDIT_DENIED;
8181
int smk_access_entry(char *subject_label, char *object_label,
8282
struct list_head *rule_list)
8383
{
84-
int may = -ENOENT;
8584
struct smack_rule *srp;
8685

8786
list_for_each_entry_rcu(srp, rule_list, list) {
8887
if (srp->smk_object->smk_known == object_label &&
8988
srp->smk_subject->smk_known == subject_label) {
90-
may = srp->smk_access;
91-
break;
89+
int may = srp->smk_access;
90+
/*
91+
* MAY_WRITE implies MAY_LOCK.
92+
*/
93+
if ((may & MAY_WRITE) == MAY_WRITE)
94+
may |= MAY_LOCK;
95+
return may;
9296
}
9397
}
9498

95-
/*
96-
* MAY_WRITE implies MAY_LOCK.
97-
*/
98-
if ((may & MAY_WRITE) == MAY_WRITE)
99-
may |= MAY_LOCK;
100-
return may;
99+
return -ENOENT;
101100
}
102101

103102
/**

security/smack/smack_lsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
static DEFINE_MUTEX(smack_ipv6_lock);
5555
static LIST_HEAD(smk_ipv6_port_list);
5656
struct kmem_cache *smack_rule_cache;
57-
int smack_enabled;
57+
int smack_enabled __initdata;
5858

5959
#define A(s) {"smack"#s, sizeof("smack"#s) - 1, Opt_##s}
6060
static struct {

0 commit comments

Comments
 (0)