public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Yizhuo Zhai <yzhai003@ucr.edu>
Cc: dchinner@redhat.com, bfoster@redhat.com,
	allison.henderson@oracle.com, chandanrlinux@gmail.com,
	linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: A Potential Bug in fs/xfs/libxfs/xfs_bmap.c
Date: Sat, 12 Jun 2021 13:19:39 -0700	[thread overview]
Message-ID: <20210612201939.GE2945763@locust> (raw)
In-Reply-To: <CABvMjLSDhy8witCZCm3ZHaWZ+E7S8NeQm8oc+sP6HSObZeUUqw@mail.gmail.com>

[cc list]

On Fri, Jun 11, 2021 at 11:12:18PM -0700, Yizhuo Zhai wrote:
> Hi All:
> I just found a bug in the cramfs using the static analysis tool, but not

cramfs?  I thought we were in xfs.  Well, I get turned around easily.

> sure if this could happen in reality, could you please advise here? Thanks
> for your attention : )
> 
> In function xfs_bmap_del_extent_real
> <https://elixir.bootlin.com/linux/v5.12/source/fs/xfs/libxfs/v5.12/C/ident/xfs_bmap_del_extent_real>()
> , the structure "got" could be uninitialized if function "
> xfs_iext_get_extent
> <https://elixir.bootlin.com/linux/v5.12/source/fs/xfs/libxfs/v5.12/C/ident/xfs_iext_get_extent>()"
> returns false. However, there's no check for the return value but it is
> still used in the later code.

What's the state of the iext cursor?  Has it moved since the last time
anyone validated it?

--D

> 
> Here's the related code:
> 
> STATIC int xfs_bmap_del_extent_real ()
> {
>         struct xfs_bmbt_irec	got; //"got" declared here but not initialized
>         xfs_iext_get_extent(ifp, icur, &got); //"got" could be
> uninitialized if xfs_iext_get_extent() return false.
> 
> 
>         ASSERT(got.br_startoff <= del->br_startoff); //"got" is used
> here and later code
> }bool
> xfs_iext_get_extent(
> 	struct xfs_ifork	*ifp,
> 	struct xfs_iext_cursor	*cur,
> 	struct xfs_bmbt_irec	*gotp)
> {
> 	if (!xfs_iext_valid(ifp, cur))
> 		return false;
>         ...
> }
> 
> 
> 
> -- 
> Kind Regards,
> 
> *Yizhuo Zhai*
> 
> *Computer Science, Graduate Student*
> *University of California, Riverside *

           reply	other threads:[~2021-06-12 20:19 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CABvMjLSDhy8witCZCm3ZHaWZ+E7S8NeQm8oc+sP6HSObZeUUqw@mail.gmail.com>]

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=20210612201939.GE2945763@locust \
    --to=djwong@kernel.org \
    --cc=allison.henderson@oracle.com \
    --cc=bfoster@redhat.com \
    --cc=chandanrlinux@gmail.com \
    --cc=dchinner@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=yzhai003@ucr.edu \
    /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