mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pankaj Kumar <pankaj.k2@samsung.com>
To: linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, casey@schaufler-ca.com
Subject: [Patch] Linux Security Module - SMACK bugfix patch
Date: Wed, 08 Jan 2014 09:34:19 +0000 (GMT)	[thread overview]
Message-ID: <DC.EF.14383.B9B1DC25@epcpsbgx3.samsung.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1829 bytes --]

Hi all

Please find attached bugfix patch for SMACK Linux security module. 

This patch fixes following bugs in smack_lsm.c file : 
1. In order to remove any SMACK extended attribute from a file, a user should have CAP_MAC_ADMIN capability. 
But user without this capability is able to remove SMACK64MMAP security attribute. 
This error has been corrected by a modification in smack_inode_removexattr SMACK hook.

2. While setting extended attribute in smack_inode_setsecurity hook, 
"-EACCES" error is getting returned if extended attribute size or value is not correct. 
But this is not correct error to be returned as extended attribute is invalid
so we should return "-EINVAL" error. 
To correct this problem now we are returning "-EINVAL" error.

---
 security/smack/smack_lsm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index b0be893..b0e6552 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -951,7 +951,7 @@ static int smack_inode_removexattr(struct dentry *dentry, const char *name)
 	    strcmp(name, XATTR_NAME_SMACKIPOUT) == 0 ||
 	    strcmp(name, XATTR_NAME_SMACKEXEC) == 0 ||
 	    strcmp(name, XATTR_NAME_SMACKTRANSMUTE) == 0 ||
-	    strcmp(name, XATTR_NAME_SMACKMMAP)) {
+	    strcmp(name, XATTR_NAME_SMACKMMAP) == 0) {
 		if (!smack_privileged(CAP_MAC_ADMIN))
 			rc = -EPERM;
 	} else
@@ -2089,7 +2089,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 	int rc = 0;
 
 	if (value == NULL || size > SMK_LONGLABEL || size == 0)
-		return -EACCES;
+		return -EINVAL;
 
 	skp = smk_import_entry(value, size);
 	if (skp == NULL)
-- 
1.8.1.2

In case of any issue, Please feel free to contact me.

Thanks & Regards
Pankaj Kumar

[-- Attachment #2: 0001-bugfix-patch-for-SMACK.patch --]
[-- Type: application/octet-stream, Size: 1505 bytes --]

From 759f6e587cc7019aa9f959168b0c155dfab123d2 Mon Sep 17 00:00:00 2001
From: Pankaj Kumar <pankaj.k2@samsung.com>
Date: Fri, 13 Dec 2013 15:12:22 +0530
Subject: [PATCH] bugfix patch for SMACK

1. In order to remove any SMACK extended attribute from a file, a user
should have CAP_MAC_ADMIN capability. But user without having this
capability is able to remove SMACK64MMAP security attribute.

2. While validating size and value of smack extended attribute in
smack_inode_setsecurity hook, wrong error code is returned.
---
 security/smack/smack_lsm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index b0be893..b0e6552 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -951,7 +951,7 @@ static int smack_inode_removexattr(struct dentry *dentry, const char *name)
 	    strcmp(name, XATTR_NAME_SMACKIPOUT) == 0 ||
 	    strcmp(name, XATTR_NAME_SMACKEXEC) == 0 ||
 	    strcmp(name, XATTR_NAME_SMACKTRANSMUTE) == 0 ||
-	    strcmp(name, XATTR_NAME_SMACKMMAP)) {
+	    strcmp(name, XATTR_NAME_SMACKMMAP) == 0) {
 		if (!smack_privileged(CAP_MAC_ADMIN))
 			rc = -EPERM;
 	} else
@@ -2089,7 +2089,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 	int rc = 0;
 
 	if (value == NULL || size > SMK_LONGLABEL || size == 0)
-		return -EACCES;
+		return -EINVAL;
 
 	skp = smk_import_entry(value, size);
 	if (skp == NULL)
-- 
1.8.1.2


                 reply	other threads:[~2014-01-08  9:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DC.EF.14383.B9B1DC25@epcpsbgx3.samsung.com \
    --to=pankaj.k2@samsung.com \
    --cc=casey@schaufler-ca.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®