aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>2014-11-26 09:31:07 -0500
committerCasey Schaufler <casey@schaufler-ca.com>2015-01-19 12:18:11 -0500
commit68390ccf8b0a3470032f053d50379cfd49fbe952 (patch)
treec31c481854862a723ae06c004993d574fe229235
parent1a28979b322bb28d8f95f76f080c53dbb9a8222d (diff)
smack: fix logic in smack_inode_init_security function
In principle if this function was called with "value" == NULL and "len" not NULL it could return different results for the "len" compared to a case where "name" was not NULL. This is a hypothetical case that does not exist in the kernel, but it's a logic bug nonetheless. Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@samsung.com>
-rw-r--r--security/smack/smack_lsm.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index dcfaddd955d1..048d92e81a34 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -800,7 +800,7 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir,
800 if (name) 800 if (name)
801 *name = XATTR_SMACK_SUFFIX; 801 *name = XATTR_SMACK_SUFFIX;
802 802
803 if (value) { 803 if (value && len) {
804 rcu_read_lock(); 804 rcu_read_lock();
805 may = smk_access_entry(skp->smk_known, dsp->smk_known, 805 may = smk_access_entry(skp->smk_known, dsp->smk_known,
806 &skp->smk_rules); 806 &skp->smk_rules);
@@ -821,10 +821,9 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir,
821 *value = kstrdup(isp->smk_known, GFP_NOFS); 821 *value = kstrdup(isp->smk_known, GFP_NOFS);
822 if (*value == NULL) 822 if (*value == NULL)
823 return -ENOMEM; 823 return -ENOMEM;
824 }
825 824
826 if (len)
827 *len = strlen(isp->smk_known); 825 *len = strlen(isp->smk_known);
826 }
828 827
829 return 0; 828 return 0;
830} 829}