aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@open.eurogiciel.org>2014-04-03 07:48:41 -0400
committerCasey Schaufler <casey@schaufler-ca.com>2014-04-11 17:35:05 -0400
commit9598f4c9e7069aee8639be1e04e8af26b5a77fa2 (patch)
tree2a23f4d21a289d80e007e674cf6b7e4108404a97 /security
parent5e9ab593c2da3064136ffa1d7f712d0e957e1958 (diff)
SMACK: Fix handling value==NULL in post setxattr
The function `smack_inode_post_setxattr` is called each time that a setxattr is done, for any value of name. The kernel allow to put value==NULL when size==0 to set an empty attribute value. The systematic call to smk_import_entry was causing the dereference of a NULL pointer hence a KERNEL PANIC! The problem can be produced easily by issuing the command `setfattr -n user.data file` under bash prompt when SMACK is active. Moving the call to smk_import_entry as proposed by this patch is correcting the behaviour because the function smack_inode_post_setxattr is called for the SMACK's attributes only if the function smack_inode_setxattr validated the value and its size (what will not be the case when size==0). It also has a benefical effect to not fill the smack hash with garbage values coming from any extended attribute write. Change-Id: Iaf0039c2be9bccb6cee11c24a3b44d209101fe47 Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
Diffstat (limited to 'security')
-rw-r--r--security/smack/smack_lsm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 9a99f3c485cb..a5d86ffbf9a0 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -960,18 +960,20 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name,
960 return; 960 return;
961 } 961 }
962 962
963 skp = smk_import_entry(value, size);
964 if (strcmp(name, XATTR_NAME_SMACK) == 0) { 963 if (strcmp(name, XATTR_NAME_SMACK) == 0) {
964 skp = smk_import_entry(value, size);
965 if (skp != NULL) 965 if (skp != NULL)
966 isp->smk_inode = skp->smk_known; 966 isp->smk_inode = skp->smk_known;
967 else 967 else
968 isp->smk_inode = smack_known_invalid.smk_known; 968 isp->smk_inode = smack_known_invalid.smk_known;
969 } else if (strcmp(name, XATTR_NAME_SMACKEXEC) == 0) { 969 } else if (strcmp(name, XATTR_NAME_SMACKEXEC) == 0) {
970 skp = smk_import_entry(value, size);
970 if (skp != NULL) 971 if (skp != NULL)
971 isp->smk_task = skp; 972 isp->smk_task = skp;
972 else 973 else
973 isp->smk_task = &smack_known_invalid; 974 isp->smk_task = &smack_known_invalid;
974 } else if (strcmp(name, XATTR_NAME_SMACKMMAP) == 0) { 975 } else if (strcmp(name, XATTR_NAME_SMACKMMAP) == 0) {
976 skp = smk_import_entry(value, size);
975 if (skp != NULL) 977 if (skp != NULL)
976 isp->smk_mmap = skp; 978 isp->smk_mmap = skp;
977 else 979 else