diff options
Diffstat (limited to 'security/smack/smack_lsm.c')
-rw-r--r-- | security/smack/smack_lsm.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index eefbd10e408f..8825375cc031 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -582,7 +582,7 @@ static void smack_inode_free_security(struct inode *inode) | |||
582 | * Returns 0 if it all works out, -ENOMEM if there's no memory | 582 | * Returns 0 if it all works out, -ENOMEM if there's no memory |
583 | */ | 583 | */ |
584 | static int smack_inode_init_security(struct inode *inode, struct inode *dir, | 584 | static int smack_inode_init_security(struct inode *inode, struct inode *dir, |
585 | const struct qstr *qstr, char **name, | 585 | const struct qstr *qstr, const char **name, |
586 | void **value, size_t *len) | 586 | void **value, size_t *len) |
587 | { | 587 | { |
588 | struct inode_smack *issp = inode->i_security; | 588 | struct inode_smack *issp = inode->i_security; |
@@ -591,11 +591,8 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir, | |||
591 | char *dsp = smk_of_inode(dir); | 591 | char *dsp = smk_of_inode(dir); |
592 | int may; | 592 | int may; |
593 | 593 | ||
594 | if (name) { | 594 | if (name) |
595 | *name = kstrdup(XATTR_SMACK_SUFFIX, GFP_NOFS); | 595 | *name = XATTR_SMACK_SUFFIX; |
596 | if (*name == NULL) | ||
597 | return -ENOMEM; | ||
598 | } | ||
599 | 596 | ||
600 | if (value) { | 597 | if (value) { |
601 | rcu_read_lock(); | 598 | rcu_read_lock(); |
@@ -3065,6 +3062,8 @@ static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap, | |||
3065 | { | 3062 | { |
3066 | struct smack_known *skp; | 3063 | struct smack_known *skp; |
3067 | int found = 0; | 3064 | int found = 0; |
3065 | int acat; | ||
3066 | int kcat; | ||
3068 | 3067 | ||
3069 | if ((sap->flags & NETLBL_SECATTR_MLS_LVL) != 0) { | 3068 | if ((sap->flags & NETLBL_SECATTR_MLS_LVL) != 0) { |
3070 | /* | 3069 | /* |
@@ -3081,12 +3080,28 @@ static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap, | |||
3081 | list_for_each_entry(skp, &smack_known_list, list) { | 3080 | list_for_each_entry(skp, &smack_known_list, list) { |
3082 | if (sap->attr.mls.lvl != skp->smk_netlabel.attr.mls.lvl) | 3081 | if (sap->attr.mls.lvl != skp->smk_netlabel.attr.mls.lvl) |
3083 | continue; | 3082 | continue; |
3084 | if (memcmp(sap->attr.mls.cat, | 3083 | /* |
3085 | skp->smk_netlabel.attr.mls.cat, | 3084 | * Compare the catsets. Use the netlbl APIs. |
3086 | SMK_CIPSOLEN) != 0) | 3085 | */ |
3087 | continue; | 3086 | if ((sap->flags & NETLBL_SECATTR_MLS_CAT) == 0) { |
3088 | found = 1; | 3087 | if ((skp->smk_netlabel.flags & |
3089 | break; | 3088 | NETLBL_SECATTR_MLS_CAT) == 0) |
3089 | found = 1; | ||
3090 | break; | ||
3091 | } | ||
3092 | for (acat = -1, kcat = -1; acat == kcat; ) { | ||
3093 | acat = netlbl_secattr_catmap_walk( | ||
3094 | sap->attr.mls.cat, acat + 1); | ||
3095 | kcat = netlbl_secattr_catmap_walk( | ||
3096 | skp->smk_netlabel.attr.mls.cat, | ||
3097 | kcat + 1); | ||
3098 | if (acat < 0 || kcat < 0) | ||
3099 | break; | ||
3100 | } | ||
3101 | if (acat == kcat) { | ||
3102 | found = 1; | ||
3103 | break; | ||
3104 | } | ||
3090 | } | 3105 | } |
3091 | rcu_read_unlock(); | 3106 | rcu_read_unlock(); |
3092 | 3107 | ||
@@ -3877,12 +3892,12 @@ static __init void init_smack_known_list(void) | |||
3877 | /* | 3892 | /* |
3878 | * Create the known labels list | 3893 | * Create the known labels list |
3879 | */ | 3894 | */ |
3880 | list_add(&smack_known_huh.list, &smack_known_list); | 3895 | smk_insert_entry(&smack_known_huh); |
3881 | list_add(&smack_known_hat.list, &smack_known_list); | 3896 | smk_insert_entry(&smack_known_hat); |
3882 | list_add(&smack_known_star.list, &smack_known_list); | 3897 | smk_insert_entry(&smack_known_star); |
3883 | list_add(&smack_known_floor.list, &smack_known_list); | 3898 | smk_insert_entry(&smack_known_floor); |
3884 | list_add(&smack_known_invalid.list, &smack_known_list); | 3899 | smk_insert_entry(&smack_known_invalid); |
3885 | list_add(&smack_known_web.list, &smack_known_list); | 3900 | smk_insert_entry(&smack_known_web); |
3886 | } | 3901 | } |
3887 | 3902 | ||
3888 | /** | 3903 | /** |