From: Lukasz Pawelczyk Date: Wed, 26 Nov 2014 14:31:07 +0000 (+0100) Subject: BACKPORT: smack: fix logic in smack_inode_init_security function X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6e06f49facaa8a045a5ff9638a35479d989148f;p=platform%2Fkernel%2Flinux-stable.git BACKPORT: 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 (cherry-picked from upstream 68390ccf8b0a3470032f053d50379cfd49fbe952) --- diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index ef1e935de508..fc3070e0a008 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -803,7 +803,7 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir, return -ENOMEM; } - if (value) { + if (value && len) { rcu_read_lock(); may = smk_access_entry(skp->smk_known, dsp->smk_known, &skp->smk_rules); @@ -824,10 +824,9 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir, *value = kstrdup(isp->smk_known, GFP_NOFS); if (*value == NULL) return -ENOMEM; - } - if (len) *len = strlen(isp->smk_known); + } return 0; }