public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ramon de Carvalho Valle <ramon@risesecurity.org>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Christoph Hellwig <hch@infradead.org>,
	xfs@oss.sgi.com, hch@lst.de, linux-kernel@vger.kernel.org,
	mszeredi@novell.com
Subject: Re: [PATCH 1/1] XFS: __xfs_get_blocks check pointer to the target device
Date: Tue, 04 Aug 2009 15:50:13 -0300	[thread overview]
Message-ID: <1249411813.7576.17.camel@logos> (raw)
In-Reply-To: <4A786110.8090404@sandeen.net>

[-- Attachment #1: Type: text/plain, Size: 2036 bytes --]

On Tue, 2009-08-04 at 11:25 -0500, Eric Sandeen wrote:
> Ramon de Carvalho Valle wrote:
> > On Mon, 2009-08-03 at 17:49 -0400, Christoph Hellwig wrote:
> >> On Mon, Aug 03, 2009 at 05:03:28PM -0300, Ramon de Carvalho Valle wrote:
> >>> The __xfs_get_blocks function does not check if the pointer to the target
> >>> device is valid before dereferencing it.
> >> It should never be zero.  It's set by xfs_imap_to_bmap to either
> >> mp->m_ddev_targp which is always allocated, or to mp->m_rtdev_targp
> >> which is always allocated if we have a realtime device, and
> >> XFS_IS_REALTIME_INODE should only be true in that case.
> >>
> > 
> > While testing XFS code with a modified version of fsfuzzer on SLES 10
> > SP3 (Kernel 2.6.16.60-0.49.3.ramon-ppc64), I came across the following
> > Oops:
> 
> ...
> 
> ahah, useful information that would have been great in the original
> patch submission.  :)

Sorry about that. :)

> 
> > I added a printk() line just before the:
> > 
> > 	bh_result->b_bdev = iomap.iomap_target->bt_bdev;
> > 
> > and as we can see iomap.iomap_target is NULL.
> > 
> > My guess is that the XFS_DIFLAG_REALTIME flag is being set incorrectly
> > on the xfs inode structure, setting iomapp->iomap_target to the wrong
> > device pointer (probably NULL).
> > 
> > I don't know if this is the best place to add a check, neither if
> > returning -XFS_ERROR(EIO) is correct at this point. Maybe doing:
> > 
> > 	if (iomap.iomap_target && omap.iomap_flags & IOMAP_REALTIME)
> > 		bh_result->b_bdev = iomap.iomap_target->bt_bdev;
> > 
> > would be a better solution.
> 
> Can you test hch's patch w/ your fuzzed image?

I tested it on my SLES 10 SP3 (Kernel 2.6.16.60-0.49.3.ramon-ppc64) and
it successfully fixed the NULL pointer dereference.

I did some small modifications to the patch to xfs error print the flags
value and fixed the xfs error report tags. I am submitting the Christoph
patch again.

Thanks Christoph and Eric.

-Ramon

> 
> Thanks,
> -Eric

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2009-08-04 18:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-03 20:03 [PATCH 1/1] XFS: __xfs_get_blocks check pointer to the target device Ramon de Carvalho Valle
2009-08-03 21:49 ` Christoph Hellwig
2009-08-04  2:00   ` Ramon de Carvalho Valle
2009-08-04 14:31     ` Christoph Hellwig
2009-08-04 16:25     ` Eric Sandeen
2009-08-04 18:50       ` Ramon de Carvalho Valle [this message]
2009-08-04 18:51       ` [PATCH 1/1] XFS: xfs_iformat realtime device target pointer check Ramon de Carvalho Valle
2009-08-04 19:11         ` Eric Sandeen
2009-08-05  3:55           ` Ramon de Carvalho Valle
2009-08-05  4:15             ` Eric Sandeen
2009-08-05 13:21               ` Ramon de Carvalho Valle
2009-08-05 21:53               ` Felix Blyakher
2009-08-05 15:17         ` Christoph Hellwig
2009-08-05 16:34           ` Ramon de Carvalho Valle

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=1249411813.7576.17.camel@logos \
    --to=ramon@risesecurity.org \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mszeredi@novell.com \
    --cc=sandeen@sandeen.net \
    --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