All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darrel Goeddel <dgoeddel@TrustedCS.com>
To: Stephen Smalley <sds@epoch.ncsc.mil>
Cc: "James Morris" <jmorris@redhat.com>,
	"selinux@tycho.nsa.gov" <selinux@tycho.nsa.gov>,
	"Chad Hanson" <chanson@TrustedCS.com>,
	"Lorenzo Hernández García-Hierro" <lorenzo@gnu.org>
Subject: Re: [PATCH] devpts xattr support
Date: Mon, 13 Jun 2005 16:01:49 -0500	[thread overview]
Message-ID: <42ADF43D.9080002@trustedcs.com> (raw)
In-Reply-To: <1118691161.24565.147.camel@moss-spartans.epoch.ncsc.mil>

Stephen Smalley wrote:
> Below is a simple patch that does this for getxattr.  ls -Z then works
> for e.g. /proc /dev/pts /selinux.
> 
> Index: linux-2.6/fs/xattr.c
> ===================================================================
> RCS file: /nfshome/pal/CVS/linux-2.6/fs/xattr.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 xattr.c
> --- linux-2.6/fs/xattr.c	27 Dec 2004 15:09:17 -0000	1.9
> +++ linux-2.6/fs/xattr.c	31 May 2005 12:56:27 -0000
> @@ -142,15 +142,19 @@ getxattr(struct dentry *d, char __user *
>  		if (error)
>  			goto out;
>  		error = d->d_inode->i_op->getxattr(d, kname, kvalue, size);
> -		if (error > 0) {
> -			if (size && copy_to_user(value, kvalue, error))
> -				error = -EFAULT;
> -		} else if (error == -ERANGE && size >= XATTR_SIZE_MAX) {
> -			/* The file system tried to returned a value bigger
> -			   than XATTR_SIZE_MAX bytes. Not possible. */
> -			error = -E2BIG;
> -		}
> +	} else if (!strncmp(kname, XATTR_SECURITY_PREFIX, sizeof XATTR_SECURITY_PREFIX - 1)) {

What about the case of an xattr handle being present that does not support security
attributes?  Or the case where an appropriate handler exists but there is no data stored
on the filesystem (I think this still happens for directories that are mounted over at
install time on Fedora Core).  Changing the above to:

	}
	if ((error == -EOPNOTSUPP || error == -ENODATA) &&
	    !strncmp(kname, XATTR_SECURITY_PREFIX, sizeof XATTR_SECURITY_PREFIX - 1)) {

would handle those cases as well (I think that gets em all).

> +		const char *suffix = kname + sizeof XATTR_SECURITY_PREFIX - 1;
> +		error = security_inode_getsecurity(d->d_inode, suffix, kvalue, size);

Shouldn't we also check security_inode_getxattr before going ahead with the
security_ionde_getxattr_checkin the "fallback" case?  

>  	}
> +	if (error > 0) {
> +		if (size && copy_to_user(value, kvalue, error))
> +			error = -EFAULT;
> +	} else if (error == -ERANGE && size >= XATTR_SIZE_MAX) {
> +		/* The file system tried to returned a value bigger
> +		   than XATTR_SIZE_MAX bytes. Not possible. */
> +		error = -E2BIG;
> +	} 
> +
>  out:
>  	if (kvalue)
>  		kfree(kvalue);
> 
> 

-- 

Darrel

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  reply	other threads:[~2005-06-13 21:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-26 14:14 [PATCH] devpts xattr support Darrel Goeddel
2004-10-26 14:42 ` Stephen Smalley
2004-10-26 18:00   ` Darrel Goeddel
2004-10-27 14:15     ` Stephen Smalley
2004-10-27 14:33       ` James Morris
2004-10-27 18:10         ` Darrel Goeddel
2004-10-27 18:31           ` James Morris
2005-06-13 19:32             ` Stephen Smalley
2005-06-13 21:01               ` Darrel Goeddel [this message]
2005-06-14 13:15                 ` Stephen Smalley
2005-06-16 14:45                   ` Darrel Goeddel
2004-10-27 17:18       ` Colin Walters
2004-10-26 18:04   ` Luke Kenneth Casson Leighton

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=42ADF43D.9080002@trustedcs.com \
    --to=dgoeddel@trustedcs.com \
    --cc=chanson@TrustedCS.com \
    --cc=jmorris@redhat.com \
    --cc=lorenzo@gnu.org \
    --cc=sds@epoch.ncsc.mil \
    --cc=selinux@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.