linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: kambarov@berkeley.edu, zkambarov@coverity.com
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: coverity-fs-udf-namei-null-check.patch added to -mm tree
Date: Sat, 25 Jun 2005 02:39:57 +0400	[thread overview]
Message-ID: <200506250239.59864.adobriyan@gmail.com> (raw)
In-Reply-To: <200506242122.j5OLMXeK013299@shell0.pdx.osdl.net>

On Saturday 25 June 2005 01:23, akpm@osdl.org wrote:
> "dir" was dereferenced before null check

> --- 25/fs/udf/namei.c~coverity-fs-udf-namei-null-check
> +++ 25-akpm/fs/udf/namei.c
> @@ -159,7 +159,7 @@ udf_find_entry(struct inode *dir, struct
>  	char *nameptr;
>  	uint8_t lfi;
>  	uint16_t liu;
> -	loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
> +	loff_t size;
>  	kernel_lb_addr bloc, eloc;
>  	uint32_t extoffset, elen, offset;
>  	struct buffer_head *bh = NULL;
> @@ -167,6 +167,8 @@ udf_find_entry(struct inode *dir, struct
>  	if (!dir)
>  		return NULL;
>  
> +	size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
> +

Let's see...

udf_find_entry() is called from:
1. udf_lookup(dir, ...)
	udf_find_entry(dir, dentry, &fibh, &cfi);

2. udf_rmdir(dir, ...)
	udf_find_entry(dir, dentry, &fibh, &cfi);

3. udf_unlink(dir, ...)
	udf_find_entry(dir, dentry, &fibh, &cfi);

4. udf_rename(old_dir, old_dentry, new_dir, new_dentry)
	udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi);
	udf_find_entry(new_dir, new_dentry, &nfibh, &ncfi);
	udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi);

So the question boils down to:
Can one call 
	1. ->lookup(NULL, ...)			or
	2. ->rmdir(NULL, ...)			or
	3. ->unlink(NULL, ...)			or
	4a. ->rename(NULL, ..., ..., ...)	or
	4b. ->rename(..., ..., NULL, ...)	?

1.

fs/namei.c:416:                 result = dir->i_op->lookup(dir, dentry, nd);
fs/namei.c:1084:                dentry = inode->i_op->lookup(inode, new, nd);

2.

fs/namei.c:1797:                        error = dir->i_op->rmdir(dir, dentry);

3.

fs/namei.c:1871:                        error = dir->i_op->unlink(dir, dentry);

4.

fs/namei.c:2138:                error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
	=> Can one do vfs_rename_dir(..., ..., NULL, ...) ?
fs/namei.c:2172:                error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
	=> Can one do vfs_rename_other(..., ..., NULL, ...) ?

Both are called in vfs_rename(..., ..., new_dir, ...) where new_dir is passed
to may_create(new_dir, ..., ...) or may_delete(new_dir, ..., ...). Both
unconditionally dereference first argument.

Have I missed something?

           reply	other threads:[~2005-06-24 22:34 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <200506242122.j5OLMXeK013299@shell0.pdx.osdl.net>]

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=200506250239.59864.adobriyan@gmail.com \
    --to=adobriyan@gmail.com \
    --cc=akpm@osdl.org \
    --cc=kambarov@berkeley.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zkambarov@coverity.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 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).