mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 06:04:23 +08:00
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>
This commit is contained in:
parent
1a28979b32
commit
68390ccf8b
@ -800,7 +800,7 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir,
|
||||
if (name)
|
||||
*name = XATTR_SMACK_SUFFIX;
|
||||
|
||||
if (value) {
|
||||
if (value && len) {
|
||||
rcu_read_lock();
|
||||
may = smk_access_entry(skp->smk_known, dsp->smk_known,
|
||||
&skp->smk_rules);
|
||||
@ -821,10 +821,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user