public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: David Chinner <dgc@sgi.com>
Cc: xfs-masters@oss.sgi.com, xfs@oss.sgi.com, linux-kernel@vger.kernel.org
Subject: Re: fs/xfs/xfs_vnodeops.c:xfs_readdir(): NULL variable dereferenced
Date: Sat, 8 Jul 2006 21:46:09 +0200	[thread overview]
Message-ID: <20060708194609.GB5020@stusta.de> (raw)
In-Reply-To: <20060706233246.GB15160733@melbourne.sgi.com>

On Fri, Jul 07, 2006 at 09:32:46AM +1000, David Chinner wrote:
> On Thu, Jul 06, 2006 at 11:13:20PM +0200, Adrian Bunk wrote:
> > The Coverity checker spotted the following:
> > 
> > <--  snip  -->
> > 
> > ...
> > STATIC int
> > xfs_readdir(
> >         bhv_desc_t      *dir_bdp,
> >         uio_t           *uiop,
> >         cred_t          *credp,
> >         int             *eofp)
> > {
> >         xfs_inode_t     *dp;
> >         xfs_trans_t     *tp = NULL;
> >         int             error = 0;
> >         uint            lock_mode;
> > 
> >         vn_trace_entry(BHV_TO_VNODE(dir_bdp), __FUNCTION__,
> >                                                (inst_t *)__return_address);
> >         dp = XFS_BHVTOI(dir_bdp);
> > 
> >         if (XFS_FORCED_SHUTDOWN(dp->i_mount))
> >                 return XFS_ERROR(EIO);
> > 
> >         lock_mode = xfs_ilock_map_shared(dp);
> >         error = xfs_dir_getdents(tp, dp, uiop, eofp);
> >         xfs_iunlock_map_shared(dp, lock_mode);
> >         return error;
> > }
> > ...
> > 
> > <--  snip  -->
> > 
> > Note that tp is never assigned any value other than NULL (and the 
> > Coverity checker found a way how tp might be dereferenced four function 
> > calls later).
> 
> Then the bug is probably in the function call that uses tp without
> first checking whether it's null. Can you tell us where that dereference
> occurs?

xfs_readdir()
  xfs_dir_getdents()
    xfs_dir2_leaf_getdents()
      xfs_bmapi()
        xfs_trans_log_inode()
          tp->t_flags |= XFS_TRANS_DIRTY;

> Cheers,
> 
> Dave.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


  parent reply	other threads:[~2006-07-08 19:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-06 21:13 fs/xfs/xfs_vnodeops.c:xfs_readdir(): NULL variable dereferenced Adrian Bunk
2006-07-06 23:32 ` David Chinner
2006-07-06 23:37   ` Hua Zhong
2006-07-08 19:46   ` Adrian Bunk [this message]
2006-07-09  1:04     ` [xfs-masters] " Nathan Scott

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=20060708194609.GB5020@stusta.de \
    --to=bunk@stusta.de \
    --cc=dgc@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xfs-masters@oss.sgi.com \
    --cc=xfs@oss.sgi.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