All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Eric Paris <eparis@redhat.com>
Cc: selinux@tycho.nsa.gov, jmorris@namei.org, paul.moore@hp.com
Subject: Re: [PATCH 1/2] SELinux: NULL terminate al contexts from disk
Date: Fri, 13 Feb 2009 08:50:37 -0500	[thread overview]
Message-ID: <1234533037.24702.0.camel@localhost.localdomain> (raw)
In-Reply-To: <20090212195005.25556.94754.stgit@paris.rdu.redhat.com>

On Thu, 2009-02-12 at 14:50 -0500, Eric Paris wrote:
> When a context is pulled in from disk we don't know that it is null
> terminated.  This patch forecebly null terminates contexts when we pull
> them from disk.
> 
> Signed-off-by: Eric Paris <eparis@redhat.com>

Acked-by:  Stephen Smalley <sds@tycho.nsa.gov>

> ---
> 
>  security/selinux/hooks.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 45e286c..4afaeac 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -1290,12 +1290,13 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
>  		}
>  
>  		len = INITCONTEXTLEN;
> -		context = kmalloc(len, GFP_NOFS);
> +		context = kmalloc(len+1, GFP_NOFS);
>  		if (!context) {
>  			rc = -ENOMEM;
>  			dput(dentry);
>  			goto out_unlock;
>  		}
> +		context[len] = '\0';
>  		rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
>  					   context, len);
>  		if (rc == -ERANGE) {
> @@ -1308,12 +1309,13 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
>  			}
>  			kfree(context);
>  			len = rc;
> -			context = kmalloc(len, GFP_NOFS);
> +			context = kmalloc(len+1, GFP_NOFS);
>  			if (!context) {
>  				rc = -ENOMEM;
>  				dput(dentry);
>  				goto out_unlock;
>  			}
> +			context[len] = '\0';
>  			rc = inode->i_op->getxattr(dentry,
>  						   XATTR_NAME_SELINUX,
>  						   context, len);
-- 
Stephen Smalley
National Security Agency


--
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.

  parent reply	other threads:[~2009-02-13 13:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-12 19:50 [PATCH 1/2] SELinux: NULL terminate al contexts from disk Eric Paris
2009-02-12 19:50 ` [PATCH 2/2] SELinux: check seqno when updating an avc_node Eric Paris
2009-02-13 14:07   ` Stephen Smalley
2009-02-13 15:06     ` Eric Paris
2009-02-13 20:19       ` Stephen Smalley
2009-02-13 20:19   ` Stephen Smalley
2009-02-13 22:44   ` James Morris
2009-02-12 20:46 ` [PATCH 1/2] SELinux: NULL terminate al contexts from disk Paul Moore
2009-02-13 13:50 ` Stephen Smalley [this message]
2009-02-13 22:43 ` James Morris

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=1234533037.24702.0.camel@localhost.localdomain \
    --to=sds@tycho.nsa.gov \
    --cc=eparis@redhat.com \
    --cc=jmorris@namei.org \
    --cc=paul.moore@hp.com \
    --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.