diff options
author | Etienne Basset <etienne.basset@numericable.fr> | 2009-03-31 23:54:11 +0200 |
---|---|---|
committer | Chris Wright <chrisw@sous-sol.org> | 2009-04-27 10:36:51 -0700 |
commit | 97ecdadc284e820931f27c6345b0ff8b85792346 (patch) | |
tree | e5b71a128283ca506587df1e99d2d30f201d38d8 | |
parent | 8d7bff2d72660d9d60aa371ae3d1356bbf329a09 (diff) |
security/smack: fix oops when setting a size 0 SMACK64 xattr
upstream commit: 4303154e86597885bc3cbc178a48ccbc8213875f
this patch fix an oops in smack when setting a size 0 SMACK64 xattr eg
attr -S -s SMACK64 -V '' somefile
This oops because smk_import_entry treats a 0 length as SMK_MAXLEN
Signed-off-by: Etienne Basset <etienne.basset@numericable.fr>
Reviewed-by: James Morris <jmorris@namei.org>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
-rw-r--r-- | security/smack/smack_lsm.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index e7ded1326b0f..c1c5f3663b18 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -607,6 +607,8 @@ static int smack_inode_setxattr(struct dentry *dentry, const char *name, strcmp(name, XATTR_NAME_SMACKIPOUT) == 0) { if (!capable(CAP_MAC_ADMIN)) rc = -EPERM; + if (size == 0) + rc = -EINVAL; } else rc = cap_inode_setxattr(dentry, name, value, size, flags); @@ -1430,7 +1432,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name, struct socket *sock; int rc = 0; - if (value == NULL || size > SMK_LABELLEN) + if (value == NULL || size > SMK_LABELLEN || size == 0) return -EACCES; sp = smk_import(value, size); |