kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] security: testing the wrong variable in create_by_name()
@ 2010-04-22 10:05 Dan Carpenter
  2010-04-22 11:18 ` [patch] security: testing the wrong variable in James Morris
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-04-22 10:05 UTC (permalink / raw)
  To: James Morris
  Cc: Eric Paris, linux-kernel, kernel-janitors, linux-security-module

There is a typo here.  We should be testing "*dentry" instead of
"dentry".  If "*dentry" is an ERR_PTR, it gets dereferenced in either
mkdir() or create() which would cause an OOPs.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/security/inode.c b/security/inode.c
index c3a7938..1c812e8 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -161,13 +161,13 @@ static int create_by_name(const char *name, mode_t mode,
 
 	mutex_lock(&parent->d_inode->i_mutex);
 	*dentry = lookup_one_len(name, parent, strlen(name));
-	if (!IS_ERR(dentry)) {
+	if (!IS_ERR(*dentry)) {
 		if ((mode & S_IFMT) = S_IFDIR)
 			error = mkdir(parent->d_inode, *dentry, mode);
 		else
 			error = create(parent->d_inode, *dentry, mode);
 	} else
-		error = PTR_ERR(dentry);
+		error = PTR_ERR(*dentry);
 	mutex_unlock(&parent->d_inode->i_mutex);
 
 	return error;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] security: testing the wrong variable in
  2010-04-22 10:05 [patch] security: testing the wrong variable in create_by_name() Dan Carpenter
@ 2010-04-22 11:18 ` James Morris
  0 siblings, 0 replies; 2+ messages in thread
From: James Morris @ 2010-04-22 11:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Eric Paris, linux-kernel, kernel-janitors, linux-security-module

On Thu, 22 Apr 2010, Dan Carpenter wrote:

> There is a typo here.  We should be testing "*dentry" instead of
> "dentry".  If "*dentry" is an ERR_PTR, it gets dereferenced in either
> mkdir() or create() which would cause an OOPs.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Looks correct -- queued for Linus.


> 
> diff --git a/security/inode.c b/security/inode.c
> index c3a7938..1c812e8 100644
> --- a/security/inode.c
> +++ b/security/inode.c
> @@ -161,13 +161,13 @@ static int create_by_name(const char *name, mode_t mode,
>  
>  	mutex_lock(&parent->d_inode->i_mutex);
>  	*dentry = lookup_one_len(name, parent, strlen(name));
> -	if (!IS_ERR(dentry)) {
> +	if (!IS_ERR(*dentry)) {
>  		if ((mode & S_IFMT) = S_IFDIR)
>  			error = mkdir(parent->d_inode, *dentry, mode);
>  		else
>  			error = create(parent->d_inode, *dentry, mode);
>  	} else
> -		error = PTR_ERR(dentry);
> +		error = PTR_ERR(*dentry);
>  	mutex_unlock(&parent->d_inode->i_mutex);
>  
>  	return error;
> 

-- 
James Morris
<jmorris@namei.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-22 11:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-22 10:05 [patch] security: testing the wrong variable in create_by_name() Dan Carpenter
2010-04-22 11:18 ` [patch] security: testing the wrong variable in James Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).