mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@intel.com>
To: Casey Schaufler <casey@schaufler-ca.com>
Cc: linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	Jarkko Sakkinen <jarkko.sakkinen@intel.com>
Subject: [PATCH] Smack: Use secureexec with SMACK64EXEC
Date: Tue, 20 Sep 2011 15:37:34 +0300	[thread overview]
Message-ID: <1316522254-23193-1-git-send-email-jarkko.sakkinen@intel.com> (raw)

SMACK64EXEC extended attribute allows switching to
another security context when executing a file.

This patch enables secureexec bit in ELF auxiliary
vector so that code cannot be injected from executers
security context.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@intel.com>
---
 security/smack/smack.h     |    5 +++++
 security/smack/smack_lsm.c |   15 ++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/security/smack/smack.h b/security/smack/smack.h
index 2b6c6a5..e41fb07 100644
--- a/security/smack/smack.h
+++ b/security/smack/smack.h
@@ -181,6 +181,11 @@ struct smack_known {
 #define SMK_NUM_ACCESS_TYPE 4
 
 /*
+ * Passed in the bprm->unsafe field
+ */
+#define SMK_SECUREEXEC_NEEDED 0x8000
+
+/*
  * Smack audit data; is empty if CONFIG_AUDIT not set
  * to save some stack
  */
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index b9c5e14..3ea018d 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -465,12 +465,24 @@ static int smack_bprm_set_creds(struct linux_binprm *bprm)
 
 	isp = dp->d_inode->i_security;
 
-	if (isp->smk_task != NULL)
+	if (isp->smk_task != NULL) {
 		tsp->smk_task = isp->smk_task;
+		bprm->unsafe = SMK_SECUREEXEC_NEEDED;
+	}
 
 	return 0;
 }
 
+int smack_bprm_secureexec(struct linux_binprm *bprm)
+{
+	int ret = cap_bprm_secureexec(bprm);
+
+	if (!ret && (bprm->unsafe & SMK_SECUREEXEC_NEEDED))
+		ret = 1;
+
+	return ret;
+}
+
 /*
  * Inode hooks
  */
@@ -3409,6 +3421,7 @@ struct security_operations smack_ops = {
 	.sb_umount = 			smack_sb_umount,
 
 	.bprm_set_creds =		smack_bprm_set_creds,
+	.bprm_secureexec =		smack_bprm_secureexec,
 
 	.inode_alloc_security = 	smack_inode_alloc_security,
 	.inode_free_security = 		smack_inode_free_security,
-- 
1.7.4.1


             reply	other threads:[~2011-09-20 12:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-20 12:37 Jarkko Sakkinen [this message]
2011-09-21 17:15 ` Stephen Smalley
2011-09-22  3:33   ` Ryan Ware
2011-09-22  7:25   ` Sakkinen, Jarkko
2011-09-22 13:28     ` Stephen Smalley

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=1316522254-23193-1-git-send-email-jarkko.sakkinen@intel.com \
    --to=jarkko.sakkinen@intel.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®