summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-08-02 15:05:10 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2022-08-02 15:05:10 -0700
commitea7099d5229c0fe9f9302b03a246e15e78b87011 (patch)
treee78067dea484209b9fbb12bac7c27d6e17c8bcba
parent1b6cf909647e64617958e6799c6e5bae413c7d0e (diff)
parentaa16fb4b9e7e1057008d999138e7ae68a40bf167 (diff)
Merge tag 'Smack-for-6.0' of https://github.com/cschaufler/smack-next
Pull msack updates from Casey Schaufler: "Two minor code clean-ups for Smack. One removes a touch of dead code and the other replaces an instance of kzalloc + strncpy with kstrndup" * tag 'Smack-for-6.0' of https://github.com/cschaufler/smack-next: smack: Remove the redundant lsm_inode_alloc smack: Replace kzalloc + strncpy with kstrndup
-rw-r--r--security/smack/smack_access.c7
-rw-r--r--security/smack/smack_lsm.c7
2 files changed, 2 insertions, 12 deletions
diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
index d2186e2757be..585e5e35710b 100644
--- a/security/smack/smack_access.c
+++ b/security/smack/smack_access.c
@@ -465,12 +465,9 @@ char *smk_parse_smack(const char *string, int len)
if (i == 0 || i >= SMK_LONGLABEL)
return ERR_PTR(-EINVAL);
- smack = kzalloc(i + 1, GFP_NOFS);
- if (smack == NULL)
+ smack = kstrndup(string, i, GFP_NOFS);
+ if (!smack)
return ERR_PTR(-ENOMEM);
-
- strncpy(smack, string, i);
-
return smack;
}
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 6207762dbdb1..001831458fa2 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -766,13 +766,6 @@ static int smack_set_mnt_opts(struct super_block *sb,
if (sp->smk_flags & SMK_SB_INITIALIZED)
return 0;
- if (inode->i_security == NULL) {
- int rc = lsm_inode_alloc(inode);
-
- if (rc)
- return rc;
- }
-
if (!smack_privileged(CAP_MAC_ADMIN)) {
/*
* Unprivileged mounts don't get to specify Smack values.