All of lore.kernel.org
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: Dan Carpenter <error27@gmail.com>,
	James Morris <jmorris@namei.org>,
	Casey Schaufler <casey@schaufler-ca.com>,
	"David P. Quigley" <dpquigl@tycho.nsa.gov>,
	David Howells <dhowells@redhat.com>,
	Serge Hallyn <serue@us.ibm.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] smack: opt_dentry is never null in in smack_d_instantiate()
Date: Wed, 02 Jun 2010 00:26:06 +0000	[thread overview]
Message-ID: <4C05A51E.1040703@schaufler-ca.com> (raw)
In-Reply-To: <20100601071404.GH5483@bicker>

Dan Carpenter wrote:
> This patch removes some unneeded code for if opt_dentry is null because
> that can never happen.
>
> The function dereferences "opt_dentry" earlier when it checks 
> "if (opt_dentry->d_parent = opt_dentry) {".  That code was added in
> 2008.
>
> This function called from security_d_instantiate().  I checked all the 
> places which call security_d_instantiate() and dentry is always non-null.
> I also checked the selinux version of this hook and there is a comment
> which says that dentry should be non-null if called from 
> d_instantiate().
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>   

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

I have tested the change and not had any issues. I recall struggling
with this particular bit of code, but that was long enough ago that
the circumstances evade my memory. Thank you.

> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 0f2fc48..07abc9c 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -2191,7 +2191,7 @@ static void smack_ipc_getsecid(struct kern_ipc_perm *ipp, u32 *secid)
>  
>  /**
>   * smack_d_instantiate - Make sure the blob is correct on an inode
> - * @opt_dentry: unused
> + * @opt_dentry: dentry where inode will be attached
>   * @inode: the object
>   *
>   * Set the inode's security blob if it hasn't been done already.
> @@ -2310,20 +2310,10 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
>  		/*
>  		 * Get the dentry for xattr.
>  		 */
> -		if (opt_dentry = NULL) {
> -			dp = d_find_alias(inode);
> -			if (dp = NULL)
> -				break;
> -		} else {
> -			dp = dget(opt_dentry);
> -			if (dp = NULL)
> -				break;
> -		}
> -
> +		dp = dget(opt_dentry);
>  		fetched = smk_fetch(inode, dp);
>  		if (fetched != NULL)
>  			final = fetched;
> -
>  		dput(dp);
>  		break;
>  	}
>
>
>   


WARNING: multiple messages have this Message-ID (diff)
From: Casey Schaufler <casey@schaufler-ca.com>
To: Dan Carpenter <error27@gmail.com>,
	James Morris <jmorris@namei.org>,
	Casey Schaufler <casey@schaufler-ca.com>,
	"David P. Quigley" <dpquigl@tycho.nsa.gov>,
	David Howells <dhowells@redhat.com>,
	Serge Hallyn <serue@us.ibm.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] smack: opt_dentry is never null in in smack_d_instantiate()
Date: Tue, 01 Jun 2010 17:26:06 -0700	[thread overview]
Message-ID: <4C05A51E.1040703@schaufler-ca.com> (raw)
In-Reply-To: <20100601071404.GH5483@bicker>

Dan Carpenter wrote:
> This patch removes some unneeded code for if opt_dentry is null because
> that can never happen.
>
> The function dereferences "opt_dentry" earlier when it checks 
> "if (opt_dentry->d_parent == opt_dentry) {".  That code was added in
> 2008.
>
> This function called from security_d_instantiate().  I checked all the 
> places which call security_d_instantiate() and dentry is always non-null.
> I also checked the selinux version of this hook and there is a comment
> which says that dentry should be non-null if called from 
> d_instantiate().
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>   

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

I have tested the change and not had any issues. I recall struggling
with this particular bit of code, but that was long enough ago that
the circumstances evade my memory. Thank you.

> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 0f2fc48..07abc9c 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -2191,7 +2191,7 @@ static void smack_ipc_getsecid(struct kern_ipc_perm *ipp, u32 *secid)
>  
>  /**
>   * smack_d_instantiate - Make sure the blob is correct on an inode
> - * @opt_dentry: unused
> + * @opt_dentry: dentry where inode will be attached
>   * @inode: the object
>   *
>   * Set the inode's security blob if it hasn't been done already.
> @@ -2310,20 +2310,10 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
>  		/*
>  		 * Get the dentry for xattr.
>  		 */
> -		if (opt_dentry == NULL) {
> -			dp = d_find_alias(inode);
> -			if (dp == NULL)
> -				break;
> -		} else {
> -			dp = dget(opt_dentry);
> -			if (dp == NULL)
> -				break;
> -		}
> -
> +		dp = dget(opt_dentry);
>  		fetched = smk_fetch(inode, dp);
>  		if (fetched != NULL)
>  			final = fetched;
> -
>  		dput(dp);
>  		break;
>  	}
>
>
>   


  reply	other threads:[~2010-06-02  0:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-01  7:14 [patch] smack: opt_dentry is never null in in smack_d_instantiate() Dan Carpenter
2010-06-01  7:14 ` Dan Carpenter
2010-06-02  0:26 ` Casey Schaufler [this message]
2010-06-02  0:26   ` Casey Schaufler
2010-06-02  1:56 ` [patch] smack: opt_dentry is never null in in James Morris
2010-06-02  1:56   ` [patch] smack: opt_dentry is never null in in smack_d_instantiate() 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=4C05A51E.1040703@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=dhowells@redhat.com \
    --cc=dpquigl@tycho.nsa.gov \
    --cc=error27@gmail.com \
    --cc=jmorris@namei.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serue@us.ibm.com \
    /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.