summaryrefslogtreecommitdiffstats
path: root/meta-rcar-gen2/recipes-kernel/linux/linux-renesas/smack/0028-SMACK-Fix-handling-value-NULL-in-post-setxattr.patch
diff options
context:
space:
mode:
authorYannick GICQUEL <yannick.gicquel@iot.bzh>2015-10-19 15:57:07 +0200
committerGerrit Code Review <gerrit@172.30.200.200>2015-11-06 15:23:36 +0000
commitede19ea0c47fb23f3fc779833d1e57cf76f3371e (patch)
tree47d6fae2283c54def1871aaf2a73828ac68b1b34 /meta-rcar-gen2/recipes-kernel/linux/linux-renesas/smack/0028-SMACK-Fix-handling-value-NULL-in-post-setxattr.patch
parent1cd8ab18abca96e4ee108f80225058d875b28347 (diff)
kernel: smack security backport from kernel 4
Here is the backport of all patches relating to smack support on kernel side. For more details, see file: meta-rcar-gen2/recipes-kernel/linux/linux-renesas/smack/README Please note that patches are applied only if "smack" is in the ditro features. Here are the 2 lines to add in the local.conf OVERRIDES .= ":smack" DISTRO_FEATURES_append = " smack" Change-Id: I147a3532aec531f977d6ec34c576261835711f1e Signed-off-by: Yannick GICQUEL <yannick.gicquel@iot.bzh> Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'meta-rcar-gen2/recipes-kernel/linux/linux-renesas/smack/0028-SMACK-Fix-handling-value-NULL-in-post-setxattr.patch')
-rw-r--r--meta-rcar-gen2/recipes-kernel/linux/linux-renesas/smack/0028-SMACK-Fix-handling-value-NULL-in-post-setxattr.patch64
1 files changed, 64 insertions, 0 deletions
diff --git a/meta-rcar-gen2/recipes-kernel/linux/linux-renesas/smack/0028-SMACK-Fix-handling-value-NULL-in-post-setxattr.patch b/meta-rcar-gen2/recipes-kernel/linux/linux-renesas/smack/0028-SMACK-Fix-handling-value-NULL-in-post-setxattr.patch
new file mode 100644
index 0000000..1ad5727
--- /dev/null
+++ b/meta-rcar-gen2/recipes-kernel/linux/linux-renesas/smack/0028-SMACK-Fix-handling-value-NULL-in-post-setxattr.patch
@@ -0,0 +1,64 @@
+From c6b962ba0e84d84cb8434aae62108b537de04c2c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jos=C3=A9=20Bollo?= <jose.bollo@open.eurogiciel.org>
+Date: Thu, 3 Apr 2014 13:48:41 +0200
+Subject: [PATCH 28/54] SMACK: Fix handling value==NULL in post setxattr
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+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>
+---
+ security/smack/smack_lsm.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
+index b47fd5f..e6c0a57 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,
+ return;
+ }
+
+- skp = smk_import_entry(value, size);
+ if (strcmp(name, XATTR_NAME_SMACK) == 0) {
++ skp = smk_import_entry(value, size);
+ if (skp != NULL)
+ isp->smk_inode = skp->smk_known;
+ else
+ isp->smk_inode = smack_known_invalid.smk_known;
+ } else if (strcmp(name, XATTR_NAME_SMACKEXEC) == 0) {
++ skp = smk_import_entry(value, size);
+ if (skp != NULL)
+ isp->smk_task = skp;
+ else
+ isp->smk_task = &smack_known_invalid;
+ } else if (strcmp(name, XATTR_NAME_SMACKMMAP) == 0) {
++ skp = smk_import_entry(value, size);
+ if (skp != NULL)
+ isp->smk_mmap = skp;
+ else
+--
+2.1.4
+