Commit defc433b authored by Etienne Basset's avatar Etienne Basset Committed by James Morris

Smack: check for SMACK xattr validity in smack_inode_setxattr

the following patch moves checks for SMACK xattr validity
from smack_inode_post_setxattr (which cannot return an error to the user)
to smack_inode_setxattr (which can return an error).
Signed-off-by: default avatarEtienne Basset <etienne.basset@numericable.fr>
Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent aefe6475
...@@ -609,8 +609,12 @@ static int smack_inode_setxattr(struct dentry *dentry, const char *name, ...@@ -609,8 +609,12 @@ static int smack_inode_setxattr(struct dentry *dentry, const char *name,
strcmp(name, XATTR_NAME_SMACKIPOUT) == 0) { strcmp(name, XATTR_NAME_SMACKIPOUT) == 0) {
if (!capable(CAP_MAC_ADMIN)) if (!capable(CAP_MAC_ADMIN))
rc = -EPERM; rc = -EPERM;
/* a label cannot be void and cannot begin with '-' */ /*
if (size == 0 || (size > 0 && ((char *)value)[0] == '-')) * check label validity here so import wont fail on
* post_setxattr
*/
if (size == 0 || size >= SMK_LABELLEN ||
smk_import(value, size) == NULL)
rc = -EINVAL; rc = -EINVAL;
} else } else
rc = cap_inode_setxattr(dentry, name, value, size, flags); rc = cap_inode_setxattr(dentry, name, value, size, flags);
...@@ -644,9 +648,6 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name, ...@@ -644,9 +648,6 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name,
if (strcmp(name, XATTR_NAME_SMACK)) if (strcmp(name, XATTR_NAME_SMACK))
return; return;
if (size >= SMK_LABELLEN)
return;
isp = dentry->d_inode->i_security; isp = dentry->d_inode->i_security;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment