From: NeilBrown <neilb@suse.de>
To: Anuj Goel <agoel@cs.stonybrook.edu>
Cc: Linux RAID <linux-raid@vger.kernel.org>
Subject: Re: [RAID0] Possible bug in raid0_make_request() function
Date: Thu, 17 May 2012 17:09:58 +1000 [thread overview]
Message-ID: <20120517170958.5ea15635@notabene.brown> (raw)
In-Reply-To: <CANSbrrqyj6wL=VBHdgDP7mpjRc+tjZnCQ6rP3_4vHYtPQPqcEA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]
On Thu, 17 May 2012 02:50:28 -0400 Anuj Goel <agoel@cs.stonybrook.edu> wrote:
> Hi Guys,
> I was going through the RAID0 code and found that there could be a
> possible bug in the raid0_make_request() function.
Thanks. I love it when people read the md/raid code and report what they
find!!
>
> Consider the below snippet of this function.
>
> /* This is a one page bio that upper layers
> * refuse to split for us, so we need to split it.
> */
> if (likely(is_power_of_2(chunk_sects)))
> bp = bio_split(bio, chunk_sects - (sector &
> (chunk_sects-1)));
> else
> bp = bio_split(bio, chunk_sects -
> sector_div(sector, chunk_sects));
> raid0_make_request(mddev, &bp->bio1);
> raid0_make_request(mddev, &bp->bio2);
> bio_pair_release(bp);
> return;
>
> In function bio_split(..), if mempool_alloc() fails, we return NULL into bp.
> Now the call raid0_make_request(mddev, &bp->bio1) does not check for
> bp to be not NULL before de-referencing it.
>
> Could this be a problem ?
No. mempool_alloc can only fail if __GFP_WAIT it not passed in,
and bio_split calls it with GFP_NOIO which contains __GFP_WAIT.
So the
if (!bp)
return bp;
at the top of bio_split is completely pointless - bp will never be NULL.
NeilBrown
>
> --
> Best Regards,
> Anuj Goel
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
prev parent reply other threads:[~2012-05-17 7:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-17 6:50 [RAID0] Possible bug in raid0_make_request() function Anuj Goel
2012-05-17 7:09 ` NeilBrown [this message]
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=20120517170958.5ea15635@notabene.brown \
--to=neilb@suse.de \
--cc=agoel@cs.stonybrook.edu \
--cc=linux-raid@vger.kernel.org \
/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).