public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org
Cc: Rob MacKinnon <c4blem0nkey@gmail.com>,
	Andreas Gruenbacher <agruen@suse.de>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	rob.mackinnon@gmail.com, hpa@zytor.com, hugh@veritas.com
Subject: [PATCH] smack inode_listsecurity fix
Date: Wed, 29 Oct 2008 08:15:50 -0700	[thread overview]
Message-ID: <49087E26.2080905@schaufler-ca.com> (raw)
In-Reply-To: <4906A871.6010501@schaufler-ca.com>

From: Casey Schaufler <casey@schaufler-ca.com>

This patch fixes the problem known by "tmpfs support of xattrs?"
which is in fact the result of a bad implementation of the
inode_listsecurity LSM hook in Smack. Thanks to Stephen Smalley,
who identified the problem and all but coded the fix before I'd
even heard about it.

Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>

---

 security/smack/smack_lsm.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff -uprN -X linux-2.6/Documentation/dontdiff linux-2.6/security/smack/smack_lsm.c linux-smack/security/smack/smack_lsm.c
--- linux-2.6/security/smack/smack_lsm.c	2008-10-26 17:37:08.000000000 -0700
+++ linux-smack/security/smack/smack_lsm.c	2008-10-26 19:11:23.000000000 -0700
@@ -763,13 +763,11 @@ static int smack_inode_getsecurity(const
 static int smack_inode_listsecurity(struct inode *inode, char *buffer,
 				    size_t buffer_size)
 {
-	int len = strlen(XATTR_NAME_SMACK);
+	int len = sizeof(XATTR_NAME_SMACK);
 
-	if (buffer != NULL && len <= buffer_size) {
+	if (buffer != NULL && len <= buffer_size)
 		memcpy(buffer, XATTR_NAME_SMACK, len);
-		return len;
-	}
-	return -EINVAL;
+	return len;
 }
 
 /**




  reply	other threads:[~2008-10-29 15:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-25  8:49 tmpfs support of xattrs? Rob MacKinnon
2008-10-25 21:59 ` H. Peter Anvin
2008-10-26 12:26 ` Hugh Dickins
2008-10-26 13:25   ` Andreas Gruenbacher
2008-10-27 20:14     ` Rob MacKinnon
2008-10-27 20:25       ` Stephen Smalley
2008-10-27 20:53         ` Andreas Gruenbacher
2008-10-27 21:12           ` Rob MacKinnon
2008-10-28  5:51             ` Casey Schaufler
2008-10-29 15:15               ` Casey Schaufler [this message]
2008-10-29 15:56               ` Rob MacKinnon
2008-10-29 16:12                 ` Casey Schaufler
2008-10-27 21:00         ` Rob MacKinnon
2008-10-27 21:54           ` Casey Schaufler

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=49087E26.2080905@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=agruen@suse.de \
    --cc=c4blem0nkey@gmail.com \
    --cc=hpa@zytor.com \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=rob.mackinnon@gmail.com \
    --cc=sds@tycho.nsa.gov \
    /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