From: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
sandeen@sandeen.net, linux-xfs@oss.sgi.com,
Tejun Heo <tj@kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
Kent Overstreet <kent.overstreet@gmail.com>
Subject: Re: [PATCH] bio allocation failure due to bio_get_nr_vecs()
Date: Fri, 11 May 2012 16:31:25 +0200 [thread overview]
Message-ID: <4FAD22BD.7010007@itwm.fraunhofer.de> (raw)
In-Reply-To: <x49sjf6vml5.fsf@segfault.boston.devel.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 606 bytes --]
On 05/11/2012 04:06 PM, Jeff Moyer wrote:
> Bernd Schubert<bernd.schubert@itwm.fraunhofer.de> writes:
>
>> diff --git a/fs/bio.c b/fs/bio.c
>> index e453924..84da885 100644
>> --- a/fs/bio.c
>> +++ b/fs/bio.c
>> @@ -505,9 +505,14 @@ EXPORT_SYMBOL(bio_clone);
>> int bio_get_nr_vecs(struct block_device *bdev)
>> {
>> struct request_queue *q = bdev_get_queue(bdev);
>> - return min_t(unsigned,
>> + int nr_pages;
>
> Looks like a corrupt patch.
What do you actually mean? Issue by thunderbird? I just saved the mail
in my sent folder and it looks? Just to be sure, patch attached.
Thanks,
Bernd
[-- Attachment #2: fix-bio-nrvec.patch --]
[-- Type: text/x-patch, Size: 1242 bytes --]
bio: bio_get_nr_vecs() must not return more than BIO_MAX_PAGES
From: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
The number of bio_get_nr_vecs() is passed down via bio_alloc() to
bvec_alloc_bs(), which fails the bio allocation if
nr_iovecs > BIO_MAX_PAGES. For the underlying caller this causes an
unexpected bio allocation failure.
Limiting to queue_max_segments() is not sufficiet, as max_segments
also might be very large.
bvec_alloc_bs(gfp_mask, nr_iovecs, ) => NULL when nr_iovecs > BIO_MAX_PAGES
bio_alloc_bioset(gfp_mask, nr_iovecs, ...)
bio_alloc(GFP_NOIO, nvecs)
xfs_alloc_ioend_bio()
Signed-off-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
---
fs/bio.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/bio.c b/fs/bio.c
index e453924..84da885 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -505,9 +505,14 @@ EXPORT_SYMBOL(bio_clone);
int bio_get_nr_vecs(struct block_device *bdev)
{
struct request_queue *q = bdev_get_queue(bdev);
- return min_t(unsigned,
+ int nr_pages;
+
+ nr_pages = min_t(unsigned,
queue_max_segments(q),
queue_max_sectors(q) / (PAGE_SIZE >> 9) + 1);
+
+ return min_t(unsigned, nr_pages, BIO_MAX_PAGES);
+
}
EXPORT_SYMBOL(bio_get_nr_vecs);
[-- Attachment #3: Type: text/plain, Size: 121 bytes --]
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-05-11 14:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-10 15:45 kernel panic / NULL pointer dereference Bernd Schubert
2012-05-10 16:17 ` Eric Sandeen
2012-05-10 16:43 ` Bernd Schubert
2012-05-11 13:49 ` [PATCH] bio allocation failure due to bio_get_nr_vecs() Bernd Schubert
2012-05-11 14:06 ` Jeff Moyer
2012-05-11 14:31 ` Bernd Schubert [this message]
2012-05-11 14:36 ` Jens Axboe
2012-05-11 16:29 ` Jeff Moyer
2012-05-11 14:36 ` Jens Axboe
2012-05-11 14:44 ` Bernd Schubert
2012-05-11 14:45 ` Jens Axboe
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=4FAD22BD.7010007@itwm.fraunhofer.de \
--to=bernd.schubert@itwm.fraunhofer.de \
--cc=axboe@kernel.dk \
--cc=jmoyer@redhat.com \
--cc=kent.overstreet@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@oss.sgi.com \
--cc=sandeen@sandeen.net \
--cc=tj@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